bitwarden-estensione-browser/apps/cli/src/services/i18n.service.ts

21 lines
719 B
TypeScript
Raw Normal View History

2021-12-20 18:04:00 +01:00
import * as fs from "fs";
import * as path from "path";
2018-05-14 17:15:54 +02:00
2021-12-20 18:04:00 +01:00
import { I18nService as BaseI18nService } from "jslib-common/services/i18n.service";
2018-05-14 17:15:54 +02:00
export class I18nService extends BaseI18nService {
2021-12-20 18:04:00 +01:00
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);
});
2018-05-14 17:15:54 +02:00
2021-12-20 18:04:00 +01:00
this.supportedTranslationLocales = ["en"];
}
2018-05-14 17:15:54 +02:00
}