diff --git a/app/language.js b/app/language.js new file mode 100644 index 00000000..6b0a6d38 --- /dev/null +++ b/app/language.js @@ -0,0 +1,145 @@ +// Create the Application's main menu +function createMenu(lang){ + const dict={ + "application":{ + "ja":"アプリケーション", + "en":"Application" + }, + "about":{ + "ja":"TheDeskについて", + "en":"About TheDesk" + }, + "quit":{ + "ja":"終了", + "en":"Quit" + }, + "edit":{ + "ja":"編集", + "en":"Edit" + }, + "undo":{ + "ja":"元に戻す", + "en":"Undo" + }, + "redo":{ + "ja":"やり直す", + "en":"Redo" + }, + "cut":{ + "ja":"切り取り", + "en":"Cut" + }, + "copy":{ + "ja":"コピー", + "en":"Copy" + }, + "paste":{ + "ja":"貼り付け", + "en":"Paste" + }, + "selall":{ + "ja":"すべて選択", + "en":"Select All" + }, + "view":{ + "ja":"表示", + "en":"View" + }, + "reload":{ + "ja":"再読み込み", + "en":"Reload" + }, + "window":{ + "ja":"ウィンドウ", + "en":"Window" + }, + "minimun":{ + "ja":"最小化", + "en":"Minimarize" + }, + "close":{ + "ja":"閉じる", + "en":"Close" + } + } + const menu = [{ + label: dict.application[lang], + submenu: [ + { label: dict.about[lang], click: function() { about(); } }, + { type: "separator" }, + { label: dict.quit[lang], accelerator: "Command+Q", click: function() { app.quit(); }} + + ]}, { + label: dict.edit[lang], + submenu: [ + { label: dict.undo[lang], accelerator: "CmdOrCtrl+Z", selector: "undo:" }, + { label: dict.redo[lang], accelerator: "Shift+CmdOrCtrl+Z", selector: "redo:" }, + { type: "separator" }, + { label: dict.cut[lang], accelerator: "CmdOrCtrl+X", selector: "cut:" }, + { label: dict.copy[lang], accelerator: "CmdOrCtrl+C", selector: "copy:" }, + { label: dict.paste[lang], accelerator: "CmdOrCtrl+V", selector: "paste:" }, + { label: dict.selall[lang], accelerator: "CmdOrCtrl+A", selector: "selectAll:" } + ]},{ + label: dict.view[lang], + submenu: [ + { + label: 'Toggle Developer Tools', + accelerator: 'Alt+Command+I', + click: function() { mainWindow.toggleDevTools(); } + }, + { + label: dict.reload[lang], + accelerator: 'CmdOrCtrl+R', + click: function() { mainWindow.webContents.send('reload', " "); } + } + ] + }, + { + label: dict.window[lang], + role: 'window', + submenu: [ + { + label: dict.minimun[lang], + accelerator: 'CmdOrCtrl+M', + role: 'minimize' + }, + { + label: dict.close[lang], + accelerator: 'CmdOrCtrl+W', + role: 'close' + }, + ] + } + ]; + return menu; +} +function delsel(lang){ + const dict={ + "delete":{ + "ja":"カラム削除", + "en":"Delete this column" + }, + "mess":{ + "ja":"カラムを削除しますか?(すべてのカラムのリンク解析がOFFになります。)", + "en":"Delete this column(URL analyzes of all windows will be disabled.)" + }, + "yes":{ + "ja":"はい", + "en":"Yes" + }, + "no":{ + "ja":"いいえ", + "en":"No" + } + } + const options = { + type: 'info', + title: dict.delete[lang], + message: dict.mess[lang], + buttons: [dict.no[lang], dict.yes[lang]] + } + return options; +} + +exports.templete = createMenu; +exports.delsel = delsel; \ No newline at end of file diff --git a/app/main.js b/app/main.js index b67921a7..6d652cbf 100644 --- a/app/main.js +++ b/app/main.js @@ -9,6 +9,7 @@ const shell = electron.shell; const os = require('os') const path = require('path') const fm = require('font-manager'); +const language = require('./language.js'); const Menu=electron.Menu var updatewin=null; const join = require('path').join; @@ -43,9 +44,20 @@ try { height: "string", x: "string", y: "string" + }; // デフォルトバリュー } - +try { + var lang = fs.readFileSync(lang_path, 'utf8'); +} catch (e) { + var lang=app.getLocale(); + if(~lang.indexOf("ja")){ + lang="ja"; + }else{ + lang="en"; + } + fs.writeFileSync(lang_path,lang); +} // 全てのウィンドウが閉じたら終了 app.on('window-all-closed', function() { if (process.platform != 'darwin') { @@ -64,17 +76,6 @@ function createWindow() { var arg={width:window_size.width,height:window_size.height,x:window_size.x,y:window_size.y,simpleFullscreen:true} } mainWindow = new BrowserWindow(arg); - try { - var lang = fs.readFileSync(lang_path, 'utf8'); - } catch (e) { - var lang=app.getLocale(); - if(~lang.indexOf("ja")){ - lang="ja"; - }else{ - lang="en"; - } - fs.writeFileSync(lang_path,lang); - } electron.session.defaultSession.clearCache(() => {}) if(process.argv){ if(process.argv[1]){ @@ -119,60 +120,11 @@ function createWindow() { mainWindow.on('maximize', function() { fs.writeFileSync(max_info_path, JSON.stringify(mainWindow.getBounds())); }); - // Create the Application's main menu - var template = [{ - label: "アプリケーション", - submenu: [ - { label: "TheDeskについて", click: function() { about(); } }, - { type: "separator" }, - { label: "終了", accelerator: "Command+Q", click: function() { app.quit(); }} - - ]}, { - label: "編集", - submenu: [ - { label: "元に戻す", accelerator: "CmdOrCtrl+Z", selector: "undo:" }, - { label: "やり直し", accelerator: "Shift+CmdOrCtrl+Z", selector: "redo:" }, - { type: "separator" }, - { label: "切り取り", accelerator: "CmdOrCtrl+X", selector: "cut:" }, - { label: "コピー", accelerator: "CmdOrCtrl+C", selector: "copy:" }, - { label: "貼り付け", accelerator: "CmdOrCtrl+V", selector: "paste:" }, - { label: "すべて選択", accelerator: "CmdOrCtrl+A", selector: "selectAll:" } - ]},{ - label: "表示", - submenu: [ - { - label: 'Toggle Developer Tools', - accelerator: 'Alt+Command+I', - click: function() { mainWindow.toggleDevTools(); } - }, - { - label: '再読み込み', - accelerator: 'CmdOrCtrl+R', - click: function() { mainWindow.webContents.send('reload', " "); } - } - ] - }, - { - label: 'ウィンドウ', - role: 'window', - submenu: [ - { - label: '最小化', - accelerator: 'CmdOrCtrl+M', - role: 'minimize' - }, - { - label: '閉じる', - accelerator: 'CmdOrCtrl+W', - role: 'close' - }, - ] - } - ]; + var platform=process.platform; var bit=process.arch; if(platform=="darwin"){ - Menu.setApplicationMenu(Menu.buildFromTemplate(template)); + Menu.setApplicationMenu(Menu.buildFromTemplate(language.template(lang))); } } // Electronの初期化完了後に実行 @@ -455,12 +407,7 @@ ipc.on('file-select', (e, args) => { }); ipc.on('column-del', (e, args) => { -const options = { - type: 'info', - title: 'カラム削除', - message: "カラムを削除しますか?(すべてのカラムのリンク解析がOFFになります。)", - buttons: ['いいえ', 'はい'] - } + var options=delsel(lang) dialog.showMessageBox(options, function(index) { mainWindow.webContents.send('column-del-reply', index); })