mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
pass utilsService to i18n function
This commit is contained in:
@@ -2,9 +2,10 @@ import MainBackground from './background/main.background';
|
|||||||
|
|
||||||
// tslint:disable-next-line:variable-name
|
// tslint:disable-next-line:variable-name
|
||||||
const bg_isBackground = (window as any).bg_isBackground = true;
|
const bg_isBackground = (window as any).bg_isBackground = true;
|
||||||
|
|
||||||
// tslint:disable-next-line:variable-name
|
// tslint:disable-next-line:variable-name
|
||||||
const bg_main = (window as any).bg_main = new MainBackground();
|
const bg_main = (window as any).bg_main = new MainBackground();
|
||||||
|
|
||||||
// tslint:disable-next-line:no-var-requires
|
// tslint:disable-next-line:no-var-requires
|
||||||
require('./scripts/analytics.js');
|
require('./scripts/analytics.js');
|
||||||
|
|
||||||
bg_main.bootstrap();
|
bg_main.bootstrap();
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export default class MainBackground {
|
|||||||
constructor() {
|
constructor() {
|
||||||
// Services
|
// Services
|
||||||
this.utilsService = new UtilsService();
|
this.utilsService = new UtilsService();
|
||||||
this.i18nService = i18nService();
|
this.i18nService = i18nService(this.utilsService);
|
||||||
this.constantsService = new ConstantsService(i18nService, this.utilsService);
|
this.constantsService = new ConstantsService(i18nService, this.utilsService);
|
||||||
this.cryptoService = new CryptoService();
|
this.cryptoService = new CryptoService();
|
||||||
this.tokenService = new TokenService();
|
this.tokenService = new TokenService();
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
export default function i18nService() {
|
import UtilsService from '../services/utils.service';
|
||||||
|
|
||||||
|
export default function i18nService(utilsService: UtilsService) {
|
||||||
const edgeMessages: any = {};
|
const edgeMessages: any = {};
|
||||||
|
|
||||||
if (navigator.userAgent.indexOf(' Edge/') !== -1) {
|
if (utilsService.isEdge()) {
|
||||||
fetch('../_locales/en/messages.json')
|
fetch('../_locales/en/messages.json').then((file) => {
|
||||||
.then((file) => {
|
return file.json();
|
||||||
return file.json();
|
}).then((locales) => {
|
||||||
})
|
for (const prop in locales) {
|
||||||
.then((locales) => {
|
if (locales.hasOwnProperty(prop)) {
|
||||||
for (const prop in locales) {
|
edgeMessages[prop] = chrome.i18n.getMessage(prop);
|
||||||
if (locales.hasOwnProperty(prop)) {
|
|
||||||
edgeMessages[prop] = chrome.i18n.getMessage(prop);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return edgeMessages;
|
return edgeMessages;
|
||||||
}
|
}
|
||||||
@@ -22,8 +22,6 @@ export default function i18nService() {
|
|||||||
return chrome.i18n.getMessage(name);
|
return chrome.i18n.getMessage(name);
|
||||||
},
|
},
|
||||||
set(target, name, value) {
|
set(target, name, value) {
|
||||||
throw new Error('set not allowed for i18n');
|
|
||||||
// @ts-ignore: Unreachable code error
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user