aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared/src
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-04-03 02:05:40 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-05-16 00:54:59 +0200
commit49c622189cf1d2c489b963d9be2f7493543afa3a (patch)
tree87636e0c08ce6ee2258566e3e0879707c9a51ea7 /packages/shared/src
parentbuild: Allow command line arguments to watch (diff)
downloadsophie-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/shared/src')
-rw-r--r--packages/shared/src/index.ts4
-rw-r--r--packages/shared/src/stores/GlobalSettingsBase.ts3
-rw-r--r--packages/shared/src/stores/SharedStoreBase.ts4
3 files changed, 8 insertions, 3 deletions
diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts
index 51f9f06..c4de885 100644
--- a/packages/shared/src/index.ts
+++ b/packages/shared/src/index.ts
@@ -18,8 +18,6 @@
18 * SPDX-License-Identifier: AGPL-3.0-only 18 * SPDX-License-Identifier: AGPL-3.0-only
19 */ 19 */
20 20
21export const fallbackLng = ['en'];
22
23export type { default as SophieRenderer } from './contextBridge/SophieRenderer'; 21export type { default as SophieRenderer } from './contextBridge/SophieRenderer';
24 22
25export { MainToRendererIpcMessage, RendererToMainIpcMessage } from './ipc'; 23export { MainToRendererIpcMessage, RendererToMainIpcMessage } from './ipc';
@@ -44,6 +42,7 @@ export type {
44export { 42export {
45 default as GlobalSettingsBase, 43 default as GlobalSettingsBase,
46 defineGlobalSettingsModel, 44 defineGlobalSettingsModel,
45 SYSTEM_LOCALE,
47} from './stores/GlobalSettingsBase'; 46} from './stores/GlobalSettingsBase';
48 47
49export { default as Profile } from './stores/Profile'; 48export { default as Profile } from './stores/Profile';
@@ -79,4 +78,5 @@ export type {
79export { 78export {
80 default as SharedStoreBase, 79 default as SharedStoreBase,
81 defineSharedStoreModel, 80 defineSharedStoreModel,
81 FALLBACK_LOCALE,
82} from './stores/SharedStoreBase'; 82} from './stores/SharedStoreBase';
diff --git a/packages/shared/src/stores/GlobalSettingsBase.ts b/packages/shared/src/stores/GlobalSettingsBase.ts
index 1bd0628..c74c822 100644
--- a/packages/shared/src/stores/GlobalSettingsBase.ts
+++ b/packages/shared/src/stores/GlobalSettingsBase.ts
@@ -30,10 +30,13 @@ import { ThemeSource } from '../schemas/ThemeSource';
30 30
31import ServiceBase from './ServiceBase'; 31import ServiceBase from './ServiceBase';
32 32
33export const SYSTEM_LOCALE = 'system';
34
33export function defineGlobalSettingsModel<TS extends IAnyModelType>( 35export function defineGlobalSettingsModel<TS extends IAnyModelType>(
34 service: TS, 36 service: TS,
35) { 37) {
36 return types.model('GlobalSettings', { 38 return types.model('GlobalSettings', {
39 language: SYSTEM_LOCALE,
37 themeSource: types.optional( 40 themeSource: types.optional(
38 types.enumeration(ThemeSource.options), 41 types.enumeration(ThemeSource.options),
39 'system', 42 'system',
diff --git a/packages/shared/src/stores/SharedStoreBase.ts b/packages/shared/src/stores/SharedStoreBase.ts
index 86bd0fc..a576a0e 100644
--- a/packages/shared/src/stores/SharedStoreBase.ts
+++ b/packages/shared/src/stores/SharedStoreBase.ts
@@ -31,6 +31,8 @@ import GlobalSettingsBase from './GlobalSettingsBase';
31import ProfileBase from './Profile'; 31import ProfileBase from './Profile';
32import ServiceBase from './ServiceBase'; 32import ServiceBase from './ServiceBase';
33 33
34export const FALLBACK_LOCALE = 'en';
35
34export function defineSharedStoreModel< 36export function defineSharedStoreModel<
35 TG extends IAnyModelType, 37 TG extends IAnyModelType,
36 TP extends IAnyModelType, 38 TP extends IAnyModelType,
@@ -43,7 +45,7 @@ export function defineSharedStoreModel<
43 servicesById: types.map(service), 45 servicesById: types.map(service),
44 services: types.array(types.reference(service)), 46 services: types.array(types.reference(service)),
45 shouldUseDarkColors: false, 47 shouldUseDarkColors: false,
46 language: 'en', 48 language: FALLBACK_LOCALE,
47 }); 49 });
48} 50}
49 51