1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 17:23:37 +00:00

[CSA-27] Use new dependency-free locale service for WebAuthN translations (#4557)

This commit is contained in:
Matt Bishop
2023-02-04 09:23:42 -05:00
committed by GitHub
parent dc3a0b25cb
commit dcc7846138
8 changed files with 306 additions and 254 deletions

View File

@@ -0,0 +1,31 @@
import { TranslationService as BaseTranslationService } from "@bitwarden/common/services/translation.service";
import { SupportedTranslationLocales } from "../translation-constants";
export class TranslationService extends BaseTranslationService {
private _translationLocale: string;
constructor(systemLanguage: string, localesDirectory: string) {
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;
});
this.supportedTranslationLocales = SupportedTranslationLocales;
}
get translationLocale(): string {
return this._translationLocale;
}
set translationLocale(locale: string) {
this._translationLocale = locale;
}
}