This repository has been archived by the owner on May 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* chore: Update to latest React 16.8.3 to requirements of react-i18next * feat: Scaffold basic translation with English and German * feat: Relates to #402. German translation fully working * fix: Switch back to English by default * fix: Allow user to switch between languages in preferences of context menu * feat: Translate the context menus * refactor: Remove German language. Add as separate PR * refactor: Remove blank line * docs: Update Readme with Internationalisation Add New language instructions * docs: Update Readme with Known Issues and Usage instructions * review-fix: Disabled tooltip Please fill out this field. Add High and Low tx speed * review-fix: Update license headers to be 2019 instead of 2018 * review-fix: Change ns1 to fether-electron and fether-react. Use pino.debug * fix: Add missing i18n conversion for macOS Edit menu * review-fix: Remove unused i18next browser languagedetector dependency * merge latest from master and fix conflicts * merge latest master and fix conflicts. TODO do not expose remote * fix: Do not expose remote. Only expose add and remove listener, and reload via bridge * feat: Convert new release available text to i18n
- Loading branch information
Showing
45 changed files
with
1,475 additions
and
502 deletions.
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
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,82 @@ | ||
// Copyright 2015-2019 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity. | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
import i18next from 'i18next'; | ||
import Backend from 'i18next-node-fs-backend'; | ||
import electron from 'electron'; | ||
import settings from 'electron-settings'; | ||
|
||
import { name } from '../../../../../package.json'; | ||
import Pino from '../../utils/pino'; | ||
import { en } from './locales'; | ||
|
||
let { app } = electron; | ||
const pino = Pino(); | ||
let resourceEnglishNS = {}; | ||
resourceEnglishNS[name] = en; | ||
const packageNS = Object.keys(resourceEnglishNS)[0].toString(); | ||
const moduleNS = 'i18n'; | ||
const menuNS = `${packageNS}-${moduleNS}`; | ||
|
||
const i18n = i18next; | ||
i18n | ||
.use(Backend) | ||
.init({ | ||
debug: true, | ||
defaultNS: packageNS, | ||
fallbackLng: ['en-US', 'en'], | ||
interpolation: { | ||
escapeValue: false | ||
}, | ||
lng: settings.get('fether-language') || 'en', | ||
ns: [packageNS], | ||
resources: { | ||
en: resourceEnglishNS | ||
}, | ||
saveMissing: true | ||
}) | ||
.then(() => pino.info(`${menuNS}: success`)) | ||
.catch(error => pino.info(`${menuNS}: failure`, error)); | ||
|
||
// FIXME i18n - convert all text below to i18n | ||
|
||
// https://www.i18next.com/overview/api#changelanguage | ||
i18n.changeLanguage(app.getLocale(), (err, t) => { | ||
if (err) { | ||
pino.info(`${menuNS}: Error loading language ${app.getLocale()}`, err); | ||
} | ||
}); | ||
|
||
i18next.on('initialized', options => { | ||
pino.debug(`${menuNS}: Detected initialisation of i18n`); | ||
}); | ||
|
||
i18next.on('loaded', loaded => { | ||
pino.info(`${menuNS}: Detected success loading resources: `, loaded); | ||
}); | ||
|
||
i18next.on('failedLoading', (lng, ns, msg) => { | ||
pino.info(`${menuNS}: Detected failure loading resources: `, lng, ns, msg); | ||
}); | ||
|
||
// saveMissing must be configured to `true` | ||
i18next.on('missingKey', (lngs, namespace, key, res) => { | ||
pino.info(`${menuNS}: Detected missing key: `, lngs, namespace, key, res); | ||
}); | ||
|
||
i18next.store.on('added', (lng, ns) => { | ||
pino.debug(`${menuNS}: Detected resources added: `, lng, ns); | ||
}); | ||
|
||
i18next.store.on('removed', (lng, ns) => { | ||
pino.debug(`${menuNS}: Detected resources removed: `, lng, ns); | ||
}); | ||
|
||
// https://www.i18next.com/overview/api#changelanguage | ||
i18next.on('languageChanged', lng => { | ||
pino.info(`${menuNS}: Detected language change to: `, lng); | ||
}); | ||
|
||
export default i18n; |
55 changes: 55 additions & 0 deletions
55
packages/fether-electron/src/main/app/menu/i18n/locales/en.json
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,55 @@ | ||
{ | ||
"menu": { | ||
"file": { | ||
"submenu_name": "File", | ||
"about": "About", | ||
"preferences": { | ||
"submenu_name": "Preferences", | ||
"languages": { | ||
"submenu_name": "Languages", | ||
"language": "Language", | ||
"english": "English", | ||
"german": "German" | ||
} | ||
}, | ||
"services": "Services", | ||
"hide": "Hide", | ||
"hide_others": "Hide Others", | ||
"unhide": "Unhide", | ||
"quit": "Quit" | ||
}, | ||
"edit": { | ||
"submenu_name": "Edit", | ||
"undo": "Undo", | ||
"redo": "Redo", | ||
"cut": "Cut", | ||
"copy": "Copy", | ||
"paste": "Paste", | ||
"delete": "Delete", | ||
"select_all": "Select All", | ||
"speech": { | ||
"submenu_name": "Speech", | ||
"start_speaking": "Start Speaking", | ||
"stop_speaking": "Stop Speaking" | ||
} | ||
}, | ||
"view": { | ||
"submenu_name": "View", | ||
"reload": "Reload", | ||
"toggle_developer_tools": "Toggle Developer Tools" | ||
}, | ||
"window": { | ||
"submenu_name": "Window", | ||
"close": "Close", | ||
"minimize": "Minimize", | ||
"zoom": "Zoom", | ||
"bring_all_to_front": "Bring All to Front" | ||
}, | ||
"help": { | ||
"submenu_name": "Help", | ||
"search": "Search", | ||
"learn_more": "Learn More" | ||
}, | ||
"show_hide_fether": "Show/Hide Fether" | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/fether-electron/src/main/app/menu/i18n/locales/index.js
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,3 @@ | ||
import en from './en.json'; | ||
|
||
export { en }; |
Oops, something went wrong.