You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-desktop/ts/util/i18n/translationDictionaries.ts

36 lines
970 B
TypeScript

import { en } from '../../localization/locales';
import type { LocalizerDictionary } from '../../types/Localizer';
import { i18nLog } from './shared';
let translationDictionary: LocalizerDictionary | undefined;
export function setTranslationDictionary(dictionary: LocalizerDictionary) {
if (translationDictionary) {
throw new Error('translationDictionary is already init');
}
translationDictionary = dictionary;
}
/**
* Only exported for testing, reset the dictionary to use for translations.
*/
export function resetTranslationDictionary() {
translationDictionary = undefined;
}
/**
* Returns the current dictionary to use for translations.
*/
export function getTranslationDictionary(): LocalizerDictionary {
if (translationDictionary) {
return translationDictionary;
}
i18nLog('getTranslationDictionary: dictionary not init yet. Using en.');
return en;
}
export function getFallbackDictionary(): LocalizerDictionary {
return en;
}