diff --git a/src/background.ts b/src/background.ts index 284dab6efb..67dd6f24e7 100644 --- a/src/background.ts +++ b/src/background.ts @@ -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(); diff --git a/src/background/main.background.ts b/src/background/main.background.ts index 1d4c2f871c..637024d50e 100644 --- a/src/background/main.background.ts +++ b/src/background/main.background.ts @@ -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(); diff --git a/src/services/i18n.service.ts b/src/services/i18n.service.ts index d3969d0fc5..19747d4ae4 100644 --- a/src/services/i18n.service.ts +++ b/src/services/i18n.service.ts @@ -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; }, });