Added language setting (#185)

* Added language setting

* Allow properly changing language

---------

Co-authored-by: Flashfyre <flashfireex@gmail.com>
This commit is contained in:
Miguel SandFlashfyre authored and GitHub committed 2024-04-19 14:55:01 -04:00
1 parent 86da18943d
commit 95d2ad2fb4
6 files changed
+112 -41

No files matched your search

+41 -30
View File
@@ -15,41 +15,52 @@ export interface MoveTranslations {
[key: string]: MoveTranslationEntry
}
export interface Localizable {
localize(): void;
}
const DEFAULT_LANGUAGE_OVERRIDE = '';
/**
* i18next is a localization library for maintaining and using translation resources.
*
* Q: How do I add a new language?
* A: To add a new language, create a new folder in the locales directory with the language code.
* Each language folder should contain a file for each namespace (ex. menu.ts) with the translations.
*
* Q: How do I add a new namespace?
* A: To add a new namespace, create a new file in each language folder with the translations.
* Then update the `resources` field in the init() call and the CustomTypeOptions interface.
*/
export function initI18n(): void {
let lang = 'en';
i18next.init({
lng: DEFAULT_LANGUAGE_OVERRIDE ? DEFAULT_LANGUAGE_OVERRIDE : 'en',
fallbackLng: 'en',
debug: true,
interpolation: {
escapeValue: false,
},
resources: {
en: {
menu: enMenu,
move: enMove,
if (localStorage.getItem('prLang'))
lang = localStorage.getItem('prLang');
/**
* i18next is a localization library for maintaining and using translation resources.
*
* Q: How do I add a new language?
* A: To add a new language, create a new folder in the locales directory with the language code.
* Each language folder should contain a file for each namespace (ex. menu.ts) with the translations.
*
* Q: How do I add a new namespace?
* A: To add a new namespace, create a new file in each language folder with the translations.
* Then update the `resources` field in the init() call and the CustomTypeOptions interface.
*/
i18next.init({
lng: DEFAULT_LANGUAGE_OVERRIDE ? DEFAULT_LANGUAGE_OVERRIDE : lang,
fallbackLng: 'en',
debug: true,
interpolation: {
escapeValue: false,
},
it: {
menu: itMenu,
resources: {
en: {
menu: enMenu,
move: enMove,
},
it: {
menu: itMenu,
},
fr: {
menu: frMenu,
move: frMove,
}
},
fr: {
menu: frMenu,
move: frMove,
}
},
});
});
}
// Module declared to make referencing keys in the localization files type-safe.
declare module 'i18next' {