This repository has been archived by the owner on Apr 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
Implement i18n for electron wrapper menu - Closes #768 #797
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
7d32a9f
Add json storage to store selected language
reyraa 7515df4
Create a utility to receive the default/stored language from electron
reyraa 35ea643
Initiate the apiLocale listener
reyraa da90a94
Use a generic t function to translate menu labels
reyraa ef091e2
Add listeners amd event emitters to comminicate the locale with the c…
reyraa bbee293
Add electron app translation scanning to i18n-scanner.js
yasharAyari 9331bda
Fix a bug in menu.js
yasharAyari 13b8a3e
Add i18n to main.js and use it in main.js
yasharAyari 06b4d59
Add electron menu translation strings to commmon.json
yasharAyari c248fe8
Create i18next confing for electron
yasharAyari 482ee32
Create language constant in app folder
yasharAyari d117421
Add locales folder to copy-files script
yasharAyari a1bcac1
Fix some bugs in main.js and i18n.js in app folder
yasharAyari ebf226e
Merge branch 'development' into '768-electron-menu-i18n'
yasharAyari 95275d2
Fix a bug in languages.js
yasharAyari 0f907ec
Store user selected language in a json file
yasharAyari e94a298
Update electron-json-file in package.json
yasharAyari 8dcada9
Merge branch 'development' into 768-electron-menu-i18n
yasharAyari 42e6e12
Fix a bug in common.json
yasharAyari c3175f8
Fix a bug in menu.js
yasharAyari e690f71
Fix a bug in common.json and electron menu strings to it
yasharAyari 743539a
Run npm clean and copy-files before npm run eslint in genkinsfile
yasharAyari 925b1bd
Fix a bug in menu.json
yasharAyari e8d0f05
Change some translation strings in common.json
yasharAyari c44b476
Fix a bug in ipcLocale test file
yasharAyari File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import i18n from 'i18next'; // eslint-disable-line import/no-extraneous-dependencies | ||
import languages from './languages'; | ||
|
||
const resources = Object.keys(languages).reduce((accumulator, key) => { | ||
accumulator[key] = { | ||
common: languages[key].common, | ||
}; | ||
return accumulator; | ||
}, {}); | ||
|
||
i18n | ||
.init({ | ||
fallbackLng: 'en', | ||
resources, | ||
lang: 'en', | ||
ns: ['common'], | ||
defaultNS: 'common', | ||
saveMissing: true, | ||
debug: false, | ||
}, (err, t) => { | ||
t('key'); | ||
// initialized and ready to go! | ||
console.log(`Current language used: ${i18n.language}`); //eslint-disable-line | ||
}); | ||
|
||
export default i18n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const languages = { | ||
en: { | ||
name: 'English', | ||
common: require('../build/locales/en/common.json'), | ||
}, | ||
de: { | ||
name: 'Deutsch', | ||
common: require('../build/locales/de/common.json'), | ||
}, | ||
}; | ||
|
||
export default languages; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
insendDetectedLang
but we don't need it insendUrlToRouter