From 37d981feb681eaad56f56d26a48c961dce2190eb Mon Sep 17 00:00:00 2001 From: Chlod Alejandro Date: Tue, 28 May 2024 07:02:28 +0800 Subject: [PATCH] lang: use user language --- src/DeputyLanguage.ts | 3 ++- src/wiki/Locale.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 src/wiki/Locale.ts diff --git a/src/DeputyLanguage.ts b/src/DeputyLanguage.ts index e7b582aa..da7f6b29 100644 --- a/src/DeputyLanguage.ts +++ b/src/DeputyLanguage.ts @@ -2,6 +2,7 @@ import { DeputyResources } from './DeputyResources'; import cloneRegex from './util/cloneRegex'; import error from './util/error'; import warn from './util/warn'; +import { USER_LOCALE } from './wiki/Locale'; /** * Handles internationalization and localization for Deputy and sub-modules. @@ -67,7 +68,7 @@ export default class DeputyLanguage { * * @param locale The locale to load. `window.deputyLang` by default. */ - static async loadMomentLocale( locale = window.deputyLang ) { + static async loadMomentLocale( locale = USER_LOCALE ) { if ( locale === 'en' ) { // Always loaded. return; diff --git a/src/wiki/Locale.ts b/src/wiki/Locale.ts new file mode 100644 index 00000000..e4f677e3 --- /dev/null +++ b/src/wiki/Locale.ts @@ -0,0 +1 @@ +export const USER_LOCALE = window.deputyLang ?? mw.config.get( 'wgUserLanguage' );