-
Notifications
You must be signed in to change notification settings - Fork 60
Implement i18n for electron wrapper menu - Closes #768 #797
Conversation
app/i18n.js
Outdated
const fs = require('fs'); | ||
const storage = require('electron-json-storage'); // eslint-disable-line import/no-extraneous-dependencies | ||
const osLocale = require('os-locale'); // eslint-disable-line import/no-extraneous-dependencies | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"os-locale" needs to be added to the package.json
When opening
|
app/locales/en/common.json
Outdated
"Lisk Forum": "Lisk Forum", | ||
"Report Issue...": "Report Issue...", | ||
"What's New...": "What's New..." | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to use other name then common.json
(e.g. menu.json
) for this file to make it easier to distinguish from src/locales/en/common.json
in any localization platform we will choose.
b055619
to
ef091e2
Compare
For reviewing please note I've reset the history to fix merge conflicts easier. |
app/src/menu.js
Outdated
click(item, focusedWindow) { | ||
if (focusedWindow) { | ||
const options = { | ||
buttons: ['OK'], | ||
icon: `${__dirname}/assets/lisk.png`, | ||
message: `Lisk Nano\nVersion ${app.getVersion()}\n${copyright}`, | ||
message: `${i18n.t('Lisk Nano\nVersion')} ${app.getVersion()}\n${copyright}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer the \n
not to be part of the translation string, it might be confusing to the translators. On the other hand, the version should be part of the translations string.
${i18n.t('Lisk Nano')}\n${i18n.t('Version {{version}}', { version: app.getVersion() })}
src/locales/en/common.json
Outdated
"{{count}} of entered delegate names could not be resolved:": "{{count}} of entered delegate names could not be resolved:", | ||
"{{count}} of entered delegate names could not be resolved:_plural": "{{count}} of entered delegate names could not be resolved:" | ||
"{{count}} of entered delegate names could not be resolved:_plural": "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert changes on lines 149-197. There was a problem in npm run i18n-scanner
that caused those changes, but now it should keep the strings intact.
* Sends an event to client application | ||
* @param {String} locale - the 2 letter name of the local | ||
*/ | ||
const sendDetectedLang = (locale) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sendDetectedLang
looks very similar tosendUrlToRouter
. The common pattern could be abstracted into a function, e.g.: sendEvent(eventName, data)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need event
in sendDetectedLang
but we don't need it in sendUrlToRouter
app/src/menu.js
Outdated
click() { | ||
electron.shell.openExternal('https://explorer.lisk.io'); | ||
{ | ||
type: i18n.t('separator'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be just type: 'separator',
. 'separator' is not a string in the UI.
src/locales/en/common.json
Outdated
"Last {{count}} days": "Last {{count}} day", | ||
"Last {{count}} days_plural": "Last {{count}} days", | ||
"Last {{count}} days": "Last {{count}} days", | ||
"Last {{count}} days_plural": "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two lines should not be changed. It's my bad. I've sent you wrong common.json.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it's all good. Thank you.
osLocale
to get the default locale of the browserelectron-json-storage
to store the last saved languageCloses Setup i18n in Electron menus #768