diff --git a/README.md b/README.md index 2bd3d79..a54aea0 100755 --- a/README.md +++ b/README.md @@ -4,6 +4,9 @@ Just a simple project made with electron JS to show Android Messages from Google To download the latest version, go to [release page](https://github.com/antoineguilbert/android-messages-for-desktop/releases). +![android-messages-macos](https://user-images.githubusercontent.com/16510381/42050509-71cc3c3a-7b09-11e8-8af2-419593ac033a.jpg) + + ## Todo - [ ] Add custom notification with only the app icon diff --git a/main.js b/main.js index 7e65562..ba77aca 100644 --- a/main.js +++ b/main.js @@ -26,7 +26,6 @@ function createWindow () { mainWindow = new BrowserWindow(windowOptions) //mainWindow.webContents.openDevTools(); - //mainWindow.webContents.executeJavaScript("var elements = document.getElementsByTagName('link'); while (elements[0]) elements[0].parentNode.removeChild(elements[0])"); mainWindow.loadURL(url.format({ pathname: path.join('messages.android.com'), @@ -55,19 +54,21 @@ function createWindow () { //Creating the menu function createMenu (){ + var i18n = new(require('./translations/i18n')); + const template = [ { - label: 'Edition', + label: i18n.__('Edit'), submenu: [ - {label:'Copier',role: 'copy'}, - {label:'Coller',role: 'paste'}, - {label:'Tout sélectionner',role: 'selectall'}, + {label: i18n.__('Copy'),role: 'copy'}, + {label: i18n.__('Paste'),role: 'paste'}, + {label: i18n.__('Select all'),role: 'selectall'}, {type: 'separator'}, - {label:'Recharger',accelerator: 'CmdOrCtrl+R',click (item, focusedWindow) {if (focusedWindow) focusedWindow.reload()}}, + {label: i18n.__('Reload'),accelerator: 'CmdOrCtrl+R',click (item, focusedWindow) {if (focusedWindow) focusedWindow.reload()}}, ] }, { - label: 'Fenêtre', + label: i18n.__('Window'), role: 'window' } ] @@ -77,23 +78,23 @@ function createMenu (){ template.unshift({ label: name, submenu: [ - {label:'À propos',role: 'about'}, + {label: i18n.__('About'),role: 'about'}, {type: 'separator'}, - {label:'Déconnecter le compte', click: function click() {clearAppCache(); }}, + {label: i18n.__('Disconnect account'), click: function click() {clearAppCache(); }}, {type: 'separator'}, - {label:'Masquer '+name,role: 'hide'}, - {label:'Masquer les autres',role: 'hideothers'}, - {label:'Tout afficher',role: 'unhide'}, + {label: i18n.__('Hide')+' '+name,role: 'hide'}, + {label: i18n.__('Hider others'),role: 'hideothers'}, + {label: i18n.__('Unhide'),role: 'unhide'}, {type: 'separator'}, - {label:'Quitter',role: 'quit'} + {label: i18n.__('Quit'),role: 'quit'} ] }) template[1].submenu.push() template[2].submenu = [ - {label: 'Réduire',accelerator: 'CmdOrCtrl+M',role: 'minimize'}, - {label: 'Agrandir',role: 'zoom'} + {label: i18n.__('Minimize'),accelerator: 'CmdOrCtrl+M',role: 'minimize'}, + {label: i18n.__('Zoom'),role: 'zoom'} ] } diff --git a/package.json b/package.json index 475bdef..04e7d01 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "android-messages", "productName": "Android Messages", "appId": "com.antoineguilbert.android-messages", - "version": "1.1.1", + "version": "1.1.2", "description": "Just a simple project made with electron JS to show Android Messages from Google in a app with notifications.", "main": "main.js", "scripts": { @@ -43,6 +43,7 @@ }, "dependencies": { "electron-context-menu": "^0.10.0", - "electron-window-state": "^4.1.1" + "electron-window-state": "^4.1.1", + "i18n": "^0.8.3" } } diff --git a/translations/en.js b/translations/en.js new file mode 100644 index 0000000..8d4b517 --- /dev/null +++ b/translations/en.js @@ -0,0 +1,18 @@ +{ + "Edit": "Edit", + "Cut": "Cut", + "Copy": "Copy", + "Paste": "Paste", + "Delete": "Delete", + "Select all": "Select all", + "Reload": "Reload", + "Window": "Window", + "Minimize": "Minimize", + "Zoom": "Zoom", + "About": "About", + "Disconnect account": "Disconnect account", + "Hide": "Hide", + "Hide others": "Hide others", + "Unhide": "Unhide", + "Quit": "Quit" +} diff --git a/translations/fr.js b/translations/fr.js new file mode 100644 index 0000000..a9645f1 --- /dev/null +++ b/translations/fr.js @@ -0,0 +1,18 @@ +{ + "Edit": "Édition", + "Cut": "Couper", + "Copy": "Copier", + "Paste": "Coller", + "Delete": "Supprimer", + "Select all": "Tout sélectionner", + "Reload": "Recharger", + "Window": "Fenêtre", + "Minimize": "Réduire", + "Zoom": "Agrandir", + "About": "À propos", + "Disconnect account": "Déconnecter le compte", + "Hide": "Masquer", + "Hide others": "Masquer les autres", + "Unhide": "Tout afficher", + "Quit": "Quitter" +} diff --git a/translations/i18n.js b/translations/i18n.js new file mode 100644 index 0000000..b8812f2 --- /dev/null +++ b/translations/i18n.js @@ -0,0 +1,25 @@ +//Constants +const path = require('path') +const electron = require('electron') +const fs = require('fs'); + +let loadedLanguage; +let app = electron.app; + +module.exports = i18n; + +function i18n() { + if(fs.existsSync(path.join(__dirname, app.getLocale() + '.js'))) { + loadedLanguage = JSON.parse(fs.readFileSync(path.join(__dirname, app.getLocale() + '.js'), 'utf8')); + }else{ + loadedLanguage = JSON.parse(fs.readFileSync(path.join(__dirname, 'en.js'), 'utf8')); + } +} + +i18n.prototype.__ = function(phrase) { + let translation = loadedLanguage[phrase] + if(translation === undefined) { + translation = phrase + } + return translation +}