1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-30 07:03:26 +00:00

localize menu options

This commit is contained in:
Kyle Spearrin
2018-02-09 00:21:00 -05:00
parent c76b4821c6
commit 092bdb5e07
4 changed files with 76 additions and 62 deletions

View File

@@ -1,3 +1,4 @@
import * as fs from 'fs';
import * as path from 'path';
import { I18nService as I18nServiceAbstraction } from 'jslib/abstractions/i18n.service';
@@ -73,7 +74,8 @@ export class I18nService implements I18nServiceAbstraction {
private loadMessages(locale: string, messagesObj: any): Promise<any> {
const formattedLocale = locale.replace('-', '_');
const filePath = path.join(__dirname, this.localesDirectory + '/' + formattedLocale + '/messages.json');
const locales = (window as any).require(filePath);
const localesJson = fs.readFileSync(filePath, 'utf8');
const locales = JSON.parse(localesJson.replace(/^\uFEFF/, '')); // strip the BOM
for (const prop in locales) {
if (!locales.hasOwnProperty(prop)) {
continue;