Skip to content

Commit

Permalink
Translation + Transliteration for Dhan Slides and Mool mantar (#763)
Browse files Browse the repository at this point in the history
* legend.md errors

* updating legend.md

* legend.md errors

* set up

* fixed and working

* strings.js to strings.json

* Revert "legend.md errors"

This reverts commit 04fcd4c.

* at this point legend.md is annoying

* windows = macos shortcuts

* mistakes when moved to strings.json

* fix bug where slide wouldn't empty

* Change dhan to 'Great is' in translation

* added 'sri'

* Change 'das' to 'daas'

* remove testing code

*  code review implemented but viewer isnt recieving the thing anymore

* extend to shortcut tray

* remove testing statements

* tried adding to menu.js but not work

* Typo fix while resolving conflicts.

* Dhan Guru slide fixes

* Dhan Guru slide fixes

* final code rev
  • Loading branch information
AkalUstat authored and maneetpaul committed Nov 16, 2019
1 parent a529dbb commit ee7cdf1
Show file tree
Hide file tree
Showing 10 changed files with 215 additions and 106 deletions.
17 changes: 16 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ function createViewer(ipcData) {
backgroundColor: '#000000',
});
viewerWindow.loadURL(`file://${__dirname}/www/viewer.html`);
viewerWindow.openDevTools();
viewerWindow.webContents.on('did-finish-load', () => {
viewerWindow.show();
const [width, height] = viewerWindow.getSize();
Expand Down Expand Up @@ -458,7 +459,21 @@ ipcMain.on('show-line', (event, arg) => {
createBroadcastFiles(arg);
}
});

ipcMain.on('show-text-with-translations', (event, arg) => {
lastLine = arg;
showLine(arg);
if (viewerWindow) {
viewerWindow.webContents.send('show-text-with-translations', arg);
} else {
createViewer({
send: 'show-text-with-translations',
data: arg,
});
}
if (arg.live) {
createBroadcastFiles(arg);
}
});
ipcMain.on('show-empty-slide', () => {
emptyOverlay();
});
Expand Down
6 changes: 6 additions & 0 deletions www/js/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,12 @@ module.exports = {
global.platform.ipc.send('show-empty-slide');
global.platform.ipc.send('show-text', { text, isGurmukhi, isAnnouncement });
},
sendTextWithTranslations(textWithTranslations) {
global.webview.send('show-empty-slide');
global.webview.send('show-text-with-translations', { textWithTranslations });
global.platform.ipc.send('show-empty-slide');
global.platform.ipc.send('show-text-with-translations', { textWithTranslations });
},
sendScroll(pos) {
global.platform.ipc.send('send-scroll', { pos });
},
Expand Down
6 changes: 3 additions & 3 deletions www/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const main = remote.require('./app');

const copy = require('./copy');
const search = require('./search');
const strings = require('./strings');
const strings = require('./strings.json');
const dhanGuruModal = require('./insert-slide');
const menu = require('./menu');
const themeEditor = require('./theme_editor');
Expand All @@ -33,15 +33,15 @@ function escKey() {

const slideShortcuts = {
waheguru: () => {
global.controller.sendText(strings.slideStrings.waheguru, true);
global.controller.sendText(strings.waheguru, true);
isInsertedSlide = true;
},
empty: () => {
global.controller.sendText(' ');
isInsertedSlide = true;
},
moolMantra: () => {
global.controller.sendText(strings.slideStrings.moolMantra, true);
global.controller.sendTextWithTranslations(strings.moolMantra);
isInsertedSlide = true;
},
};
Expand Down
21 changes: 18 additions & 3 deletions www/js/insert-slide.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,28 @@ const electron = require('electron');

const analytics = electron.remote.getGlobal('analytics');
const tingle = require('./vendor/tingle');
const strings = require('./strings');
const strings = require('./strings.json');
const settings = require('./settings');

const { store } = electron.remote.require('./app');

// allowed html tags inside announcement
const allowedTags = strings.allowedAnnouncementTags;
// eslint-disable-next-line prefer-destructuring
const allowedTags = [
'b',
'i',
'em',
'u',
'pre',
'strong',
'div',
'code',
'br',
'p',
'ul',
'li',
'ol',
];

/**
* boolean to check what modal page is asctive
Expand Down Expand Up @@ -99,7 +114,7 @@ function buttonOnClick() {
if (!isAnnouncementTab) {
for (let i = 1; i <= 11; i += 1) {
document.getElementById(`guru${i}`).onclick = () => {
global.controller.sendText(strings.slideStrings.dhanguruStrings[i - 1], true, false);
global.controller.sendTextWithTranslations(strings.dhanSlides[i - 1]);
global.core.updateInsertedSlide(true);
modal.close();
};
Expand Down
50 changes: 33 additions & 17 deletions www/js/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const request = require('request');
const moment = require('moment');
const electron = require('electron');
const sanitizeHtml = require('sanitize-html');
const strings = require('./strings');
const strings = require('./strings.json');

const { randomShabad } = require('./banidb');
const settings = require('./settings');
Expand All @@ -14,7 +14,21 @@ const search = require('./search');
const { store } = electron.remote.require('./app');
const analytics = electron.remote.getGlobal('analytics');

const allowedTags = strings.allowedAnnouncementTags;
const allowedTags = [
'b',
'i',
'em',
'u',
'pre',
'strong',
'div',
'code',
'br',
'p',
'ul',
'li',
'ol',
];

const modal = new tingle.Modal({
footer: true,
Expand Down Expand Up @@ -222,27 +236,29 @@ const dhanGuruSlideButton = h(
'a.dhanguru-slide-button',
{
onclick: () => {
const guruJi = document.querySelector('#dhan-guru').value;
const guruJi = document.querySelector('#dhan-guru').selectedIndex;
analytics.trackEvent('display', 'dhanguru-slide', guruJi);
global.controller.sendText(guruJi, true);
if (guruJi - 1 >= 0) {
global.controller.sendTextWithTranslations(strings.dhanSlides[guruJi - 1]);
}
},
},
h('i.fa.fa-circle-o.list-icon'),
[
h('label', { htmlFor: 'dhan-guru' }, 'Add Dhan Guru '),
h('select#dhan-guru', { value: ' ' }, [
h('option', { value: ' ' }, 'Select'),
h('option', { value: 'DMn gurU nwnk dyv jI' }, 'Nanak Dev Ji'),
h('option', { value: 'DMn gurU AMgd dyv jI' }, 'Angad Dev Ji'),
h('option', { value: 'DMn gurU Amrdwsu swihb jI' }, 'Amardas Sahib Ji'),
h('option', { value: 'DMn gurU rwmdws swihb jI' }, 'Ramdas Sahib Ji'),
h('option', { value: 'DMn gurU Arjun dyv jI' }, 'Arjun Dev Ji'),
h('option', { value: 'DMn gurU hir goibMd swihb jI' }, 'Har Gobind Sahib Ji'),
h('option', { value: 'DMn gurU hir rwie swihb jI' }, 'Har Rai Sahib Ji'),
h('option', { value: 'DMn gurU hir ikRSx swihb jI' }, 'Har Krishan Sahib Ji'),
h('option', { value: 'DMn gurU qyg bhwdr swihb jI' }, 'Teg Bahadur Sahib Ji'),
h('option', { value: 'DMn gurU goibMd isMG swihb jI' }, 'Gobind Singh Sahib Ji'),
h('option', { value: 'DMn gurU gRMQ swihb jI' }, 'Granth Sahib Ji'),
h('option', { value: `${strings.dhanSlides[0]}` }, 'Nanak Dev Ji'),
h('option', { value: `${strings.dhanSlides[1]}` }, 'Angad Dev Ji'),
h('option', { value: `${strings.dhanSlides[2]}` }, 'Amardas Sahib Ji'),
h('option', { value: `${strings.dhanSlides[3]}` }, 'Ramdas Sahib Ji'),
h('option', { value: `${strings.dhanSlides[4]}` }, 'Arjun Dev Ji'),
h('option', { value: `${strings.dhanSlides[5]}` }, 'Har Gobind Sahib Ji'),
h('option', { value: `${strings.dhanSlides[6]}` }, 'Har Rai Sahib Ji'),
h('option', { value: `${strings.dhanSlides[7]}` }, 'Har Krishan Sahib Ji'),
h('option', { value: `${strings.dhanSlides[8]}` }, 'Teg Bahadur Sahib Ji'),
h('option', { value: `${strings.dhanSlides[9]}` }, 'Gobind Singh Sahib Ji'),
h('option', { value: `${strings.dhanSlides[10]}` }, 'Granth Sahib Ji'),
]),
],
),
Expand Down Expand Up @@ -279,8 +295,8 @@ const announcementSlideButton = h(
onclick: () => {
const isGurmukhi = document.querySelector('#announcement-language').checked;
const placeholderText = isGurmukhi
? strings.announcemenetPlaceholder.gurmukhi
: strings.announcemenetPlaceholder.english;
? strings.announcement.placeholder.gurmukhi
: strings.announcement.placeholder.english;

const $announcementText = document.querySelector('.announcement-text');
$announcementText.classList.toggle('gurmukhi', isGurmukhi);
Expand Down
2 changes: 2 additions & 0 deletions www/js/shortcut_tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const trayItemFactory = (trayItemKey, trayItem) =>
global.core.search.loadCeremony(trayItem.ref).catch(error => {
analytics.trackEvent('ceremonyFailed', trayItem.ref, error);
});
} else if (trayItem.type === 'textWithTranslations') {
global.controller.sendTextWithTranslations(trayItem.ref);
}
},
},
Expand Down
51 changes: 28 additions & 23 deletions www/js/shortcut_tray.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
{
"anandSahib": {
"label": "Anand Sahib (Bhog)",
"labelType": "roman",
"type": "ceremony",
"ref": 3
},
"moolMantra": {
"label": "Mool Mantra",
"labelType": "roman",
"type": "text",
"ref": "<> siq nwmu krqw purKu inrBau inrvYru Akwl mUriq AjUnI sYBM gur pRswid ]"
},
"waheguru": {
"label": "vwihgurU",
"labelType": "gurmukhi",
"type": "text",
"ref": "vwihgurU"
},
"blank": {
"label": "Blank",
"labelType": "roman",
"type": "text",
"ref": ""
"anandSahib": {
"label": "Anand Sahib (Bhog)",
"labelType": "roman",
"type": "ceremony",
"ref": 3
},
"moolMantra": {
"label": "Mool Mantra",
"labelType": "roman",
"type": "textWithTranslations",
"ref": {
"gurmukhi": "<> siq nwmu krqw purKu inrBau inrvYru Akwl mUriq AjUnI sYBM gur pRswid ]",
"english": "One Universal Creator God. The Name Is Truth. Creative Being Personified. No Fear. No Hatred. Image Of The Undying, Beyond Birth, Self-Existent. By Guru's Grace ~",
"punjabi": "ਅਕਾਲ ਪੁਰਖ ਇੱਕ ਹੈ, ਜਿਸ ਦਾ ਨਾਮ 'ਹੋਂਦ ਵਾਲਾ' ਹੈ ਜੋ ਸ੍ਰਿਸ਼ਟੀ ਦਾ ਰਚਨਹਾਰ ਹੈ, ਜੋ ਸਭ ਵਿਚ ਵਿਆਪਕ ਹੈ, ਭੈ ਤੋਂ ਰਹਿਤ ਹੈ, ਵੈਰ-ਰਹਿਤ ਹੈ, ਜਿਸ ਦਾ ਸਰੂਪ ਕਾਲ ਤੋਂ ਪਰੇ ਹੈ, (ਭਾਵ, ਜਿਸ ਦਾ ਸਰੀਰ ਨਾਸ-ਰਹਿਤ ਹੈ), ਜੋ ਜੂਨਾਂ ਵਿਚ ਨਹੀਂ ਆਉਂਦਾ, ਜਿਸ ਦਾ ਪ੍ਰਕਾਸ਼ ਆਪਣੇ ਆਪ ਤੋਂ ਹੋਇਆ ਹੈ ਅਤੇ ਜੋ ਸਤਿਗੁਰੂ ਦੀ ਕਿਰਪਾ ਨਾਲ ਮਿਲਦਾ ਹੈ।",
"translit": " ikOankaar sat naam karataa purakh nirabhau niravair akaal moorat ajoonee saibha(n) gur prasaadh ||"
}
},
"waheguru": {
"label": "vwihgurU",
"labelType": "gurmukhi",
"type": "text",
"ref": "vwihgurU"
},
"blank": {
"label": "Blank",
"labelType": "roman",
"type": "text",
"ref": ""
}
}
57 changes: 0 additions & 57 deletions www/js/strings.js

This file was deleted.

Loading

0 comments on commit ee7cdf1

Please sign in to comment.