diff --git a/src/controllers/about.js b/src/controllers/about.js index b5858a9..ff68c15 100644 --- a/src/controllers/about.js +++ b/src/controllers/about.js @@ -7,7 +7,7 @@ module.exports = (browsers, store) => { const i18n = new(require('../i18n'))(lang) let config = { version: app.getVersion(), - i18n: i18n.asObject().About + i18n: i18n.asObject() } sendEvent('init', config) }) @@ -20,7 +20,7 @@ module.exports = (browsers, store) => { case 'langChanged': const lang = store.get('lang') const i18n = new(require('../i18n'))(lang) - win.webContents.send(event, i18n.asObject().About) + win.webContents.send(event, i18n.asObject()) break default: win.webContents.send(event, ...params) diff --git a/src/controllers/deficiency.js b/src/controllers/deficiency.js index c776b9c..a3b50ee 100644 --- a/src/controllers/deficiency.js +++ b/src/controllers/deficiency.js @@ -6,7 +6,7 @@ module.exports = (browsers, store) => { const lang = store.get('lang') const i18n = new(require('../i18n'))(lang) let config = { - i18n: i18n.asObject().Deficiency + i18n: i18n.asObject() } sendEvent('init', config) }) @@ -19,7 +19,7 @@ module.exports = (browsers, store) => { case 'langChanged': const lang = store.get('lang') const i18n = new(require('../i18n'))(lang) - win.webContents.send(event, i18n.asObject().Deficiency) + win.webContents.send(event, i18n.asObject()) break default: win.webContents.send(event, ...params) diff --git a/src/controllers/main.js b/src/controllers/main.js index 9ca3741..3765a2b 100644 --- a/src/controllers/main.js +++ b/src/controllers/main.js @@ -6,7 +6,7 @@ module.exports = (browsers, store) => { const lang = store.get('lang') const i18n = new(require('../i18n'))(lang) let config = { - i18n: i18n.asObject().Main + i18n: i18n.asObject() } sendEvent('init', config) }) @@ -23,7 +23,7 @@ module.exports = (browsers, store) => { case 'langChanged': const lang = store.get('lang') const i18n = new(require('../i18n'))(lang) - win.webContents.send(event, i18n.asObject().Main) + win.webContents.send(event, i18n.asObject()) break default: win.webContents.send(event, ...params) diff --git a/src/views/about.html b/src/views/about.html index 8993e2f..eff179a 100644 --- a/src/views/about.html +++ b/src/views/about.html @@ -1,5 +1,5 @@ - + About diff --git a/src/views/deficiency.html b/src/views/deficiency.html index f28a556..6532bd9 100644 --- a/src/views/deficiency.html +++ b/src/views/deficiency.html @@ -1,5 +1,5 @@ - + Colour blindness simulation diff --git a/src/views/js/about.js b/src/views/js/about.js index f44c1a6..518704f 100644 --- a/src/views/js/about.js +++ b/src/views/js/about.js @@ -28,7 +28,9 @@ ipcRenderer.on('langChanged', (event, i18n) => { translateHTML(i18n) }) -function translateHTML(i18n) { +function translateHTML(_i18n) { + document.querySelector('html').lang = _i18n.Main['lang'] + const i18n = _i18n["About"]; // translate html elements. document.title = i18n['Title']; document.querySelector('h1#header-main').textContent = i18n['Colour Contrast Analyser (CCA)']; diff --git a/src/views/js/deficiency.js b/src/views/js/deficiency.js index 8767643..915cf3e 100644 --- a/src/views/js/deficiency.js +++ b/src/views/js/deficiency.js @@ -27,8 +27,7 @@ ipcRenderer.on('contrastRatioChanged', (event, contrastRatio) => { applyContrastRatio(contrastRatio) }) -ipcRenderer.on('langChanged', (event, i18nNew) => { - i18n = i18nNew +ipcRenderer.on('langChanged', (event, i18n) => { translateHTML(i18n) }) @@ -49,7 +48,10 @@ function applyContrastRatio (contrastRatio) { }) } -function translateHTML(i18n) { +function translateHTML(_i18n) { + document.querySelector('html').lang = _i18n.Main['lang'] + const i18n = _i18n["Deficiency"]; + // translate html elements. document.title = i18n['Title'] document.querySelector('body > main > h1').textContent = i18n['Colour blindness simulation'] diff --git a/src/views/js/main.js b/src/views/js/main.js index 6f6bc4e..e68e21b 100644 --- a/src/views/js/main.js +++ b/src/views/js/main.js @@ -46,8 +46,8 @@ const announceForAccessibility = (message)=>{ } ipcRenderer.on('init', async (event, config) => { - i18n = config.i18n - translateHTML(i18n) + i18n = config.i18n["Main"]; + translateHTML() const theme = await store.get("colorScheme"); setColorScheme(theme); // init format selector @@ -118,8 +118,7 @@ ipcRenderer.on('colorSchemeChanged',async (event,newScheme)=>{ setColorScheme(newScheme); }) -ipcRenderer.on('langChanged', (event, i18nNew) => { - i18n = i18nNew +ipcRenderer.on('langChanged', (event, i18n) => { translateHTML(i18n) //TODO applyContrastRatio() }) @@ -336,7 +335,7 @@ function applyColorHSVSliders(section, color) { function applyColorSample(section, color) { if (section === 'foreground') { document.querySelector('#sample-preview .text').style.color = color.rgb - document.querySelector('#sample-preview .icon svg').style.stroke = color.rgb + document.querySelector('#sample-preview .icon svg').style.stroke = color.rgb } else { document.querySelector('#sample-preview .text').style.background = color.rgb document.querySelector('#sample-preview .icon').style.background = color.rgb @@ -445,8 +444,7 @@ function changeFormat(section, el) { store.set(`${section}.format`, el.value) } -function translateHTML(i18n) { - +function translateHTML() { // translate html elements. document.querySelector('html').lang = i18n['lang'] document.querySelector('title').textContent = i18n['Title'] diff --git a/src/views/js/preferences.js b/src/views/js/preferences.js index b24cba4..e831e86 100644 --- a/src/views/js/preferences.js +++ b/src/views/js/preferences.js @@ -103,12 +103,13 @@ function close() {window.close();} * @description translate html elements. */ function translateHTML(_i18n) { + document.querySelector('html').lang = _i18n.Main['lang'] const i18n = _i18n["Preferences"]; document.title = i18n['Title']; document.querySelector('h1').textContent = i18n['Preferences']; /* Options fieldset */ - document.querySelector('fieldset#options>legend').textContent = i18n['Options']; + document.querySelector('fieldset#options>legend').textContent = i18n['Options']; // Rounding Precision document.querySelector('label[for="option-rounding"]').textContent = i18n['Contrast ratio precision']; document.querySelectorAll('#option-rounding > option').forEach((opt,idx)=>{ @@ -164,8 +165,8 @@ function translateHTML(_i18n) { // background, foreground picker document.querySelector('label[for="shortcut-background-picker"]').textContent = i18n['Picker foreground']; document.querySelector('label[for="shortcut-foreground-picker"]').textContent = i18n['Picker background']; - - document.querySelector('fieldset#copy > legend').textContent = i18n['Copy results']; + + document.querySelector('fieldset#copy > legend').textContent = _i18n.Menu['Copy results']; /* Copy results fieldset */ document.querySelectorAll("#copy-format-example>li>span").forEach((el,idx)=>{ const i18nTexts = [i18n["Foreground colour in hexa format"], diff --git a/src/views/preferences.html b/src/views/preferences.html index 91ba6b3..7ab0634 100644 --- a/src/views/preferences.html +++ b/src/views/preferences.html @@ -1,6 +1,5 @@ - - + Preferences @@ -8,7 +7,6 @@ -

Preferences

diff --git a/src/views/translations/en.json b/src/views/translations/en.json index f842b16..8046446 100644 --- a/src/views/translations/en.json +++ b/src/views/translations/en.json @@ -144,7 +144,6 @@ "Electron" : "Electron", "Add-on":"Add-on", "Shortcuts": "Shortcuts", - "Copy results":"Copy results", "Picker foreground": "Picker foreground", "Picker background": "Picker background", "Reset":"Reset", diff --git a/src/views/translations/es.json b/src/views/translations/es.json index 6ea1a0e..e0ffa6a 100644 --- a/src/views/translations/es.json +++ b/src/views/translations/es.json @@ -144,7 +144,6 @@ "Electron" : "Electron", "Add-on":"Add-on", "Shortcuts": "Atajos", - "Copy results":"Copy results", "Picker foreground": "Selector de primer plano", "Picker background": "Selector de fondo", "Reset":"Reset", diff --git a/src/views/translations/fr.json b/src/views/translations/fr.json index fc90e71..e3db96f 100644 --- a/src/views/translations/fr.json +++ b/src/views/translations/fr.json @@ -11,7 +11,7 @@ "Preferences": "Préférences", "Edit": "Édition", "Copy results": "Copier les résultats", - "Copy short results": "Copy short results", + "Copy short results": "Copier les résultats (simplifiés)", "Cut": "Couper", "Copy": "Copier", "Paste": "Coller", @@ -127,16 +127,15 @@ "Electron" : "Electron", "Add-on":"Add-on", "Shortcuts": "Raccourcis", - "Copy results":"Copy results", "Picker foreground": "Sélecteur de premier plan", "Picker background": "Sélecteur d'arrière-plan", - "Reset":"Reset", - "Short results template":"Short results template", - "Regular results template":"Regular results template", - "Foreground colour in hexa format":"Foreground colour in hexa format", - "Background colour in hexa format":"background colour in hexa format", - "Contrast ratio (raw)":"Contrast ratio (raw)", - "Contrast ratio (rounded)":"Contrast ratio (rounded)", + "Reset":"Réinitialiser", + "Short results template":"Modèle de résultats courts", + "Regular results template":"Modèle de résultats complets", + "Foreground colour in hexa format":"Couleur de premier plan au format hexadécimal", + "Background colour in hexa format":"Couleur d'arrière-plan au format hexadécimal", + "Contrast ratio (raw)":"Ratio de contraste (brut)", + "Contrast ratio (rounded)":"Ratio de contraste (contraste)", "Save": "Sauvegarder", "Cancel": "Annuler", "Color Picker type": "Type de sélecteur" diff --git a/src/views/translations/hu.json b/src/views/translations/hu.json index 4b5e62a..91cae33 100644 --- a/src/views/translations/hu.json +++ b/src/views/translations/hu.json @@ -144,7 +144,6 @@ "Electron" : "Electron", "Add-on":"Add-on", "Shortcuts" : "Gyorsbillentyűk", - "Copy results":"Copy results", "Picker foreground" : "Előtérszín pipetta", "Picker background" : "Háttérszín pipetta", "Reset":"Reset", diff --git a/src/views/translations/it.json b/src/views/translations/it.json index 70d0125..b9a1d32 100644 --- a/src/views/translations/it.json +++ b/src/views/translations/it.json @@ -144,7 +144,6 @@ "Electron" : "Electron", "Add-on":"Add-on", "Shortcuts": "Tasti di scelta rapida", - "Copy results":"Copia risultati", "Picker foreground": "Selettore primo piano", "Picker background": "Selettore sfondo", "Reset":"Ripristina", diff --git a/src/views/translations/ja.json b/src/views/translations/ja.json index 00a7ed9..126c62c 100644 --- a/src/views/translations/ja.json +++ b/src/views/translations/ja.json @@ -144,7 +144,6 @@ "Electron" : "Electron", "Add-on":"Add-on", "Shortcuts": "ショートカットキー", - "Copy results":"結果コピー", "Picker foreground": "前景色ピッカー", "Picker background": "背景色ピッカー", "Reset":"リセット", diff --git a/src/views/translations/ko.json b/src/views/translations/ko.json index 53523c5..64f91f4 100644 --- a/src/views/translations/ko.json +++ b/src/views/translations/ko.json @@ -144,7 +144,6 @@ "Electron" : "일렉트론", "Add-on":"에드온", "Shortcuts": "단축키", - "Copy results":"결과 복사", "Picker foreground": "화면에서 글자 색상 선택", "Picker background": "화면에서 배경 색상 선택", "Reset":"되돌리기", diff --git a/src/views/translations/pl.json b/src/views/translations/pl.json index 91e5eb8..a857e03 100644 --- a/src/views/translations/pl.json +++ b/src/views/translations/pl.json @@ -152,7 +152,6 @@ "Contrast ratio (raw)":"Współczynnik kontrastu (surowy)", "Contrast ratio (rounded)":"Współczynnik kontrastu (zaokrąglony)", "Shortcuts": "Skróty", - "Copy results":"Skopiuj wyniki", "Picker foreground": "Próbnik koloru pierwszoplanowego", "Picker background": "Próbnik koloru tła", "Save": "Zapisz", diff --git a/src/views/translations/ru.json b/src/views/translations/ru.json index 3f8bd6a..e41283a 100644 --- a/src/views/translations/ru.json +++ b/src/views/translations/ru.json @@ -151,7 +151,6 @@ "Contrast ratio (raw)":"Contrast ratio (raw)", "Contrast ratio (rounded)":"Contrast ratio (rounded)", "Shortcuts": "Горячие клавиши", - "Copy results":"Copy results", "Picker foreground": "Пипетка для текста", "Picker background": "Пипетка для фона", "Save": "Сохранить", diff --git a/src/views/translations/zh-CN.json b/src/views/translations/zh-CN.json index bea5fac..088463c 100644 --- a/src/views/translations/zh-CN.json +++ b/src/views/translations/zh-CN.json @@ -144,7 +144,6 @@ "Electron": "Electron", "Add-on": "插件", "Shortcuts": "快捷键", - "Copy results": "复制结果", "Picker foreground": "取色器前景", "Picker background": "取色器背景", "Reset": "重置", diff --git a/src/views/translations/zh-TW.json b/src/views/translations/zh-TW.json index e84aab4..dee4c74 100644 --- a/src/views/translations/zh-TW.json +++ b/src/views/translations/zh-TW.json @@ -144,7 +144,6 @@ "Electron": "Electron", "Add-on": "插件", "Shortcuts": "快捷鍵", - "Copy results": "復製結果", "Picker foreground": "取色器前景", "Picker background": "取色器背景", "Reset": "重置",