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