From ef392b2c60c6b332555f11cd3bd224a292c9401d Mon Sep 17 00:00:00 2001 From: Vishwas Shashidhar Date: Thu, 28 Mar 2019 18:09:05 +0530 Subject: [PATCH] Fix Localisation Issues (#620) * ELECTRON-1073: localise more info window content * fix localisation on network error strings * ELECTRON-1074: fix localisation for right click context menu in child windows * ELECTRON-1097: fix japanese localisation string name for screen sharing indicator * ELECTRON-1052: add localisation support for screen names in screen sharing window --- js/desktopCapturer/renderer.js | 21 +++++++++++++++------ js/main.js | 1 + js/moreInfo/index.js | 2 ++ js/moreInfo/more-info.html | 4 ++-- js/moreInfo/renderer.js | 12 ++++++++++++ locale/en-US.json | 8 +++++++- locale/en.json | 8 +++++++- locale/fr-FR.json | 10 ++++++++-- locale/fr.json | 10 ++++++++-- locale/ja-JP.json | 12 +++++++++--- locale/ja.json | 12 +++++++++--- 11 files changed, 80 insertions(+), 20 deletions(-) diff --git a/js/desktopCapturer/renderer.js b/js/desktopCapturer/renderer.js index 58afce49..a2e3c789 100644 --- a/js/desktopCapturer/renderer.js +++ b/js/desktopCapturer/renderer.js @@ -90,13 +90,21 @@ ipcRenderer.on('desktop-capturer-sources', (event, sources, isWindowsOS) => { for (let source of sources) { screenRegExp.lastIndex = 0; - if (source.name === 'Entire screen' || screenRegExp.exec(source.name)) { + if (source.display_id !== "") { source.fileName = 'fullscreen'; - screenContent.appendChild(createItem(source)); + if (source.name === 'Entire screen') { + const screenName = localizedContent['Entire screen'] || 'Entire screen'; + screenContent.appendChild(createItem(source, screenName)); + } else { + const screenName = localizedContent['Screen {number}'] || 'Screen {number}'; + const screenNumber = source.name.substr(7, source.name.length); + const localisedScreenString = screenName.replace('{number}', screenNumber); + screenContent.appendChild(createItem(source, localisedScreenString)); + } hasScreens = true; } else { source.fileName = null; - applicationContent.appendChild(createItem(source)); + applicationContent.appendChild(createItem(source, source.name)); hasApplications = true; } } @@ -127,10 +135,11 @@ function startShare() { /** * Creates DOM elements and injects data - * @param source + * @param source Screen source + * @param name Name of the source * @returns {HTMLDivElement} */ -function createItem(source) { +function createItem(source, name) { const itemContainer = document.createElement("div"); const sectionBox = document.createElement("div"); const imageTag = document.createElement("img"); @@ -144,7 +153,7 @@ function createItem(source) { // Inject data to the dom element imageTag.src = source.thumbnail; - titleContainer.innerText = source.name; + titleContainer.innerText = name; sectionBox.appendChild(imageTag); itemContainer.id = source.id; diff --git a/js/main.js b/js/main.js index ebb8e269..181c134f 100644 --- a/js/main.js +++ b/js/main.js @@ -251,6 +251,7 @@ function onWebContent(webContents) { spellchecker.initializeSpellChecker(); spellchecker.updateContextMenuLocale(i18n.getMessageFor('ContextMenu')); const contextMenuBuilder = new ContextMenuBuilder(spellchecker.spellCheckHandler, webContents, false, spellchecker.processMenu.bind(spellchecker)); + contextMenuBuilder.setAlternateStringFormatter(spellchecker.getStringTable(i18n.getMessageFor('ContextMenu'))); let currentLocale = i18n.getLanguage(); const contextMenuListener = (event, info) => { diff --git a/js/moreInfo/index.js b/js/moreInfo/index.js index f4a02858..970de4c9 100644 --- a/js/moreInfo/index.js +++ b/js/moreInfo/index.js @@ -85,6 +85,8 @@ function openMoreInfoWindow(windowName) { }); moreInfoWindow.webContents.on('did-finish-load', () => { + const moreInfoContext = i18n.getMessageFor('MoreInfo'); + moreInfoWindow.webContents.send('i18n-more-info', moreInfoContext); // initialize crash reporter initCrashReporterMain({ process: 'more info window' }); initCrashReporterRenderer(moreInfoWindow, { process: 'render | more info window' }); diff --git a/js/moreInfo/more-info.html b/js/moreInfo/more-info.html index 56b8bbac..1c70d49c 100644 --- a/js/moreInfo/more-info.html +++ b/js/moreInfo/more-info.html @@ -2,7 +2,7 @@ - More Information +