diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-04-03 02:05:40 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2022-05-16 00:54:59 +0200 |
commit | 49c622189cf1d2c489b963d9be2f7493543afa3a (patch) | |
tree | 87636e0c08ce6ee2258566e3e0879707c9a51ea7 /packages/renderer/src/i18n | |
parent | build: Allow command line arguments to watch (diff) | |
download | sophie-49c622189cf1d2c489b963d9be2f7493543afa3a.tar.gz sophie-49c622189cf1d2c489b963d9be2f7493543afa3a.tar.zst sophie-49c622189cf1d2c489b963d9be2f7493543afa3a.zip |
feat(main): Language setting in config file
Load localization according to either the environment or the
configuration file from the list of supported locales.
Ideally, we would also set the chromium locale with --lang, but by the
time we have read the config file (to known which locale to set),
electron has already initialized the chromium resource bundle.
So the chromium localization will always be auto-detected by chromium.
Also makes startup hopefully a bit faster by doing more things
concurrently while the localization and the main window is being loaded.
Signed-off-by: Kristóf Marussy <kristof@marussy.com>
Diffstat (limited to 'packages/renderer/src/i18n')
-rw-r--r-- | packages/renderer/src/i18n/loadRendererLoalization.ts | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/packages/renderer/src/i18n/loadRendererLoalization.ts b/packages/renderer/src/i18n/loadRendererLoalization.ts index 19d1e2d..b078aeb 100644 --- a/packages/renderer/src/i18n/loadRendererLoalization.ts +++ b/packages/renderer/src/i18n/loadRendererLoalization.ts | |||
@@ -18,7 +18,7 @@ | |||
18 | * SPDX-License-Identifier: AGPL-3.0-only | 18 | * SPDX-License-Identifier: AGPL-3.0-only |
19 | */ | 19 | */ |
20 | 20 | ||
21 | import { fallbackLng, SophieRenderer } from '@sophie/shared'; | 21 | import { FALLBACK_LOCALE, SophieRenderer } from '@sophie/shared'; |
22 | import i18next from 'i18next'; | 22 | import i18next from 'i18next'; |
23 | import { autorun } from 'mobx'; | 23 | import { autorun } from 'mobx'; |
24 | import { addDisposer } from 'mobx-state-tree'; | 24 | import { addDisposer } from 'mobx-state-tree'; |
@@ -40,7 +40,7 @@ export default function loadRendererLocalization( | |||
40 | const i18n = i18next | 40 | const i18n = i18next |
41 | .createInstance({ | 41 | .createInstance({ |
42 | lng: store.shared.language, | 42 | lng: store.shared.language, |
43 | fallbackLng, | 43 | fallbackLng: [FALLBACK_LOCALE], |
44 | interpolation: { | 44 | interpolation: { |
45 | escapeValue: false, // Not needed for react | 45 | escapeValue: false, // Not needed for react |
46 | }, | 46 | }, |
@@ -73,6 +73,7 @@ export default function loadRendererLocalization( | |||
73 | shared: { language }, | 73 | shared: { language }, |
74 | } = store; | 74 | } = store; |
75 | if (i18n.language !== language) { | 75 | if (i18n.language !== language) { |
76 | log.debug('Setting language', language); | ||
76 | i18n.changeLanguage(language).catch((error) => { | 77 | i18n.changeLanguage(language).catch((error) => { |
77 | log.error('Failed to change language', error); | 78 | log.error('Failed to change language', error); |
78 | }); | 79 | }); |