1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 09:43:23 +00:00
Files
browser/apps/web/src/app/core/i18n.service.ts
Matt Gibson f4150ffda6 [PM-6511] New i18n for angular (#8122)
* 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
2024-03-11 13:59:19 -04:00

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;
}
}