ELECTRON-536: add missing translation strings (#408)

- add missing translations
- fix macOS menu load issues.
This commit is contained in:
Vishwas Shashidhar
2018-06-21 18:13:03 +05:30
committed by GitHub
parent 33f31fc507
commit 4fa422c19f
6 changed files with 57 additions and 14 deletions

View File

@@ -19,7 +19,16 @@ const getMessageFor = function(phrase) {
const setLanguage = function(lng) {
language = lng ? lng : 'en-US';
loadedTranslations = JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', 'locale', language + '.json'), 'utf8'));
let file = path.join(__dirname, '..', '..', 'locale', language + '.json');
if (!fs.existsSync(file)) {
file = path.join(__dirname, '..', '..', 'locale', 'en-US.json');
}
let data = fs.readFileSync(file, 'utf8');
try {
loadedTranslations = JSON.parse(data);
} catch (e) {
loadedTranslations = {}
}
};
/**

View File

@@ -46,6 +46,7 @@ let isAutoReload = false;
// Application menu
let menu;
let lang;
// note: this file is built using browserify in prebuild step.
const preloadMainScript = path.join(__dirname, 'preload/_preloadMain.js');
@@ -97,12 +98,14 @@ function getParsedUrl(appUrl) {
* @param initialUrl
*/
function createMainWindow(initialUrl) {
getMultipleConfigField([ 'mainWinPos', 'isCustomTitleBar' ])
getMultipleConfigField([ 'mainWinPos', 'isCustomTitleBar', 'locale' ])
.then(configData => {
lang = configData.locale || app.getLocale();
doCreateMainWindow(initialUrl, configData.mainWinPos, configData.isCustomTitleBar);
})
.catch(() => {
// failed use default bounds and frame
lang = app.getLocale();
doCreateMainWindow(initialUrl, null, false);
});
}
@@ -274,18 +277,8 @@ function doCreateMainWindow(initialUrl, initialBounds, isCustomTitleBar) {
addWindowKey(key, mainWindow);
mainWindow.loadURL(url);
getConfigField('locale')
.then((language) => {
const lang = language || app.getLocale();
log.send(`setting app language to ${lang}`);
rebuildMenu(lang);
})
.catch((err) => {
const lang = app.getLocale();
log.send(`could not find language settings ${err}, defaulting to system language ${app.getLocale()}`);
rebuildMenu(lang);
});
rebuildMenu(lang);
mainWindow.on('close', function (e) {
if (willQuitApp) {

View File

@@ -15,6 +15,10 @@
},
"Bring All to Front": "Bring All to Front",
"Bring to Front on Notifications": "Bring to Front on Notifications",
"Flash Notification in Taskbar": "Flash Notification in Taskbar",
"Title Bar Style": "Title Bar Style",
"Native With Custom": "Native With Custom",
"Custom": "Custom",
"Close": "Close",
"Copy": "Copy",
"Cut": "Cut",
@@ -56,11 +60,19 @@
"Select Screen": "Select Screen",
"Share": "Share"
},
"ScreenSnippet": {
"Pen": "Pen",
"Done": "Done",
"Snipping Tool": "Snipping Tool",
"Erase": "Erase",
"Highlight": "Highlight"
},
"Select All": "Select All",
"Services": "Services",
"Show All": "Show All",
"Show crash dump in Finder": "Show crash dump in Finder",
"Show Logs in Finder": "Show Logs in Finder",
"Show Logs in Explorer": "Show Logs in Explorer",
"Speech": "Speech",
"Start Speaking": "Start Speaking",
"Stop Speaking": "Stop Speaking",

View File

@@ -15,6 +15,10 @@
},
"Bring All to Front": "Bring All to Front",
"Bring to Front on Notifications": "Bring to Front on Notifications",
"Flash Notification in Taskbar": "Flash Notification in Taskbar",
"Title Bar Style": "Title Bar Style",
"Native With Custom": "Native With Custom",
"Custom": "Custom",
"Close": "Close",
"Copy": "Copy",
"Cut": "Cut",
@@ -56,11 +60,19 @@
"Select Screen": "Select Screen",
"Share": "Share"
},
"ScreenSnippet": {
"Pen": "Pen",
"Done": "Done",
"Snipping Tool": "Snipping Tool",
"Erase": "Erase",
"Highlight": "Highlight"
},
"Select All": "Select All",
"Services": "Services",
"Show All": "Show All",
"Show crash dump in Finder": "Show crash dump in Finder",
"Show Logs in Finder": "Show Logs in Finder",
"Show Logs in Explorer": "Show Logs in Explorer",
"Speech": "Speech",
"Start Speaking": "Start Speaking",
"Stop Speaking": "Stop Speaking",

View File

@@ -15,6 +15,10 @@
},
"Bring All to Front": "すべてを前面に表示",
"Bring to Front on Notifications": "通知の前面に表示",
"Flash Notification in Taskbar": "タスクバーのフラッシュ通知",
"Title Bar Style": "タイトルバーのスタイル",
"Native With Custom": "ネイティブ(カスタム)",
"Custom": "カスタム",
"Close": "閉じる",
"Copy": "コピー",
"Cut": "切り取り",
@@ -68,6 +72,7 @@
"Show All": "すべてを表示",
"Show crash dump in Finder": "ファインダーにクラッシュダンプを表示",
"Show Logs in Finder": "ファインダーにログを表示",
"Show Logs in Explorer": "エクスプローラにログを表示する",
"Speech": "スピーチ",
"Start Speaking": "スピーキングを始める",
"Stop Speaking": "スピーキングをやめる",

View File

@@ -15,6 +15,10 @@
},
"Bring All to Front": "すべてを前面に表示",
"Bring to Front on Notifications": "通知の前面に表示",
"Flash Notification in Taskbar": "タスクバーのフラッシュ通知",
"Title Bar Style": "タイトルバーのスタイル",
"Native With Custom": "ネイティブ(カスタム)",
"Custom": "カスタム",
"Close": "閉じる",
"Copy": "コピー",
"Cut": "切り取り",
@@ -56,11 +60,19 @@
"Select Screen": "画面の選択",
"Share": "共有"
},
"ScreenSnippet": {
"Pen": "ペン",
"Done": "完了",
"Snipping Tool": "スニッピングツール",
"Erase": "消去する",
"Highlight": "ハイライト"
},
"Select All": "すべてを選択",
"Services": "サービス",
"Show All": "すべてを表示",
"Show crash dump in Finder": "ファインダーにクラッシュダンプを表示",
"Show Logs in Finder": "ファインダーにログを表示",
"Show Logs in Explorer": "エクスプローラにログを表示する",
"Speech": "スピーチ",
"Start Speaking": "スピーキングを始める",
"Stop Speaking": "スピーキングをやめる",