ELECTRON-656 - Correct Japanese translation (#480)

This commit is contained in:
Kiran Niranjan 2018-08-29 10:39:16 +05:30 committed by Vishwas Shashidhar
parent 3306473f07
commit 154b66e195
6 changed files with 45 additions and 22 deletions

View File

@ -2,6 +2,7 @@ const { remote } = require('electron');
const { MenuItem } = remote;
const { isMac } = require('./../utils/misc');
const { SpellCheckHandler, ContextMenuListener, ContextMenuBuilder } = require('electron-spellchecker');
const stringFormat = require('./../utils/stringFormat');
class SpellCheckHelper {
@ -59,8 +60,8 @@ class SpellCheckHelper {
copyImage: () => content['Copy Image'] || 'Copy Image',
addToDictionary: () => content['Add to Dictionary'] || 'Add to Dictionary',
lookUpDefinition: (lookup) => {
const lookUp = content['Look Up '] || 'Look Up ';
return `${lookUp}"${lookup.word}"`;
const formattedString = stringFormat(content['Look Up {searchText}'], { searchText: lookup.word });
return formattedString || `Look Up ${lookup.word}`;
},
searchGoogle: () => content['Search with Google'] || 'Search with Google',
cut: () => content.Cut || 'Cut',

22
js/utils/stringFormat.js Normal file
View File

@ -0,0 +1,22 @@
/**
* Injects content into string
* @param string {String}
* @param data {Object} - content to replace
* @return {*}
*/
function stringFormat(string, data) {
for (let key in data) {
if (Object.prototype.hasOwnProperty.call(data, key)) {
return string.replace(/({([^}]+)})/g, function (i) {
let replacedKey = i.replace(/{/, '').replace(/}/, '');
if (!data[replacedKey]) {
return i;
}
return data[replacedKey];
});
}
}
return null;
}
module.exports = stringFormat;

View File

@ -26,7 +26,7 @@
"Copy Link": "Copy Link",
"Cut": "Cut",
"Inspect Element": "Inspect Element",
"Look Up ": "Look Up ",
"Look Up {searchText}": "Look Up \"{searchText}\"",
"Open Link": "Open Link",
"Paste": "Paste",
"Reload": "Reload",

View File

@ -26,7 +26,7 @@
"Copy Link": "Copy Link",
"Cut": "Cut",
"Inspect Element": "Inspect Element",
"Look Up ": "Look Up ",
"Look Up {searchText}": "Look Up \"{searchText}\"",
"Open Link": "Open Link",
"Paste": "Paste",
"Reload": "Reload",

View File

@ -20,16 +20,16 @@
"ContextMenu": {
"Add to Dictionary": "辞書に追加",
"Copy": "コピー",
"Copy Email Address": "メールアドレスをコピーする",
"Copy Image": "イメージをコピーする",
"Copy Image URL": "コピー画像のURL",
"Copy Link": "リンクをコピーする",
"Cut": "カット",
"Inspect Element": "要素の検査",
"Look Up ": "見上げる",
"Copy Email Address": "電子メールアドレスをコピー",
"Copy Image": "画像をコピー",
"Copy Image URL": "画像のURLをコピー",
"Copy Link": "リンクをコピー",
"Cut": "切り取り",
"Inspect Element": "要素を調査",
"Look Up {searchText}": "「{searchText}」を検索",
"Open Link": "リンクを開く",
"Paste": "ペースト",
"Reload": "リロード",
"Paste": "貼り付け",
"Reload": "再読み込み",
"Search with Google": "Googleで検索"
},
"DownloadManager": {

View File

@ -20,16 +20,16 @@
"ContextMenu": {
"Add to Dictionary": "辞書に追加",
"Copy": "コピー",
"Copy Email Address": "メールアドレスをコピーする",
"Copy Image": "イメージをコピーする",
"Copy Image URL": "コピー画像のURL",
"Copy Link": "リンクをコピーする",
"Cut": "カット",
"Inspect Element": "要素の検査",
"Look Up ": "見上げる",
"Copy Email Address": "電子メールアドレスをコピー",
"Copy Image": "画像をコピー",
"Copy Image URL": "画像のURLをコピー",
"Copy Link": "リンクをコピー",
"Cut": "切り取り",
"Inspect Element": "要素を調査",
"Look Up {searchText}": "「{searchText}」を検索",
"Open Link": "リンクを開く",
"Paste": "ペースト",
"Reload": "リロード",
"Paste": "貼り付け",
"Reload": "再読み込み",
"Search with Google": "Googleで検索"
},
"DownloadManager": {