mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
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
This commit is contained in:
committed by
GitHub
parent
dd5dbda122
commit
ef392b2c60
@@ -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;
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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' });
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>More Information</title>
|
||||
<title data-i18n-text="More Information"></title>
|
||||
<style>
|
||||
html, body {
|
||||
margin: 0;
|
||||
@@ -30,7 +30,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<span><b>Version Information</b></span>
|
||||
<span><b data-i18n-text="Version Information"></b></span>
|
||||
<span id="electron" class="content"></span>
|
||||
<span id="chromium" class="content"></span>
|
||||
<span id="v8" class="content"></span>
|
||||
|
||||
@@ -36,6 +36,18 @@ ipcRenderer.on('register-crash-reporter', (event, arg) => {
|
||||
}
|
||||
});
|
||||
|
||||
ipcRenderer.on('i18n-more-info', (event, content) => {
|
||||
if (content && typeof content === 'object') {
|
||||
const i18nNodes = document.querySelectorAll('[data-i18n-text]');
|
||||
|
||||
for (let node of i18nNodes) {
|
||||
if (node.attributes['data-i18n-text'] && node.attributes['data-i18n-text'].value) {
|
||||
node.innerText = content[node.attributes['data-i18n-text'].value] || node.attributes['data-i18n-text'].value;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// note: this is a workaround until
|
||||
// https://github.com/electron/electron/issues/8841
|
||||
// is fixed on the electron. where 'will-navigate'
|
||||
|
||||
Reference in New Issue
Block a user