mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 09:13:33 +00:00
[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
This commit is contained in:
@@ -2,18 +2,28 @@ import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
|
||||
import { I18nService as BaseI18nService } from "@bitwarden/common/platform/services/i18n.service";
|
||||
import { GlobalStateProvider } from "@bitwarden/common/platform/state";
|
||||
|
||||
export class I18nService extends BaseI18nService {
|
||||
constructor(systemLanguage: string, localesDirectory: string) {
|
||||
super(systemLanguage, localesDirectory, (formattedLocale: string) => {
|
||||
const filePath = path.join(
|
||||
__dirname,
|
||||
this.localesDirectory + "/" + formattedLocale + "/messages.json",
|
||||
);
|
||||
const localesJson = fs.readFileSync(filePath, "utf8");
|
||||
const locales = JSON.parse(localesJson.replace(/^\uFEFF/, "")); // strip the BOM
|
||||
return Promise.resolve(locales);
|
||||
});
|
||||
constructor(
|
||||
systemLanguage: string,
|
||||
localesDirectory: string,
|
||||
globalStateProvider: GlobalStateProvider,
|
||||
) {
|
||||
super(
|
||||
systemLanguage,
|
||||
localesDirectory,
|
||||
(formattedLocale: string) => {
|
||||
const filePath = path.join(
|
||||
__dirname,
|
||||
this.localesDirectory + "/" + formattedLocale + "/messages.json",
|
||||
);
|
||||
const localesJson = fs.readFileSync(filePath, "utf8");
|
||||
const locales = JSON.parse(localesJson.replace(/^\uFEFF/, "")); // strip the BOM
|
||||
return Promise.resolve(locales);
|
||||
},
|
||||
globalStateProvider,
|
||||
);
|
||||
|
||||
this.supportedTranslationLocales = ["en"];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user