mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 09:43:23 +00:00
* Use state provider to store preferred language * migrate preferred language * Use new i18n provider to get LOCAL_ID * Fix preloaded english i18n This is a mock service that forces english translations, it doesn't need the i18n interface that allows changing of locales. * PR improvements * Fixup merge
32 lines
954 B
TypeScript
32 lines
954 B
TypeScript
import { I18nService as BaseI18nService } from "@bitwarden/common/platform/services/i18n.service";
|
|
import { GlobalStateProvider } from "@bitwarden/common/platform/state";
|
|
|
|
import { SupportedTranslationLocales } from "../../translation-constants";
|
|
|
|
export class I18nService extends BaseI18nService {
|
|
constructor(
|
|
systemLanguage: string,
|
|
localesDirectory: string,
|
|
globalStateProvider: GlobalStateProvider,
|
|
) {
|
|
super(
|
|
systemLanguage || "en-US",
|
|
localesDirectory,
|
|
async (formattedLocale: string) => {
|
|
const filePath =
|
|
this.localesDirectory +
|
|
"/" +
|
|
formattedLocale +
|
|
"/messages.json?cache=" +
|
|
process.env.CACHE_TAG;
|
|
const localesResult = await fetch(filePath);
|
|
const locales = await localesResult.json();
|
|
return locales;
|
|
},
|
|
globalStateProvider,
|
|
);
|
|
|
|
this.supportedTranslationLocales = SupportedTranslationLocales;
|
|
}
|
|
}
|