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:
31
apps/web/src/connectors/translation.service.ts
Normal file
31
apps/web/src/connectors/translation.service.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user