safari fixes

This commit is contained in:
Kyle Spearrin 2018-01-11 23:39:16 -05:00
parent 2b6c2bd4e2
commit 61dc7454d3
3 changed files with 23 additions and 22 deletions

View File

@ -142,6 +142,7 @@ export default class MainBackground {
opr.sidebarAction : (window as any).chrome.sidebarAction;
// Background
if (!this.isSafari) {
this.commandsBackground = new CommandsBackground(this, this.passwordGenerationService);
this.contextMenusBackground = new ContextMenusBackground(this, this.cipherService,
this.passwordGenerationService);
@ -152,6 +153,7 @@ export default class MainBackground {
this.webRequestBackground = new WebRequestBackground(this.platformUtilsService, this.cipherService);
this.windowsBackground = new WindowsBackground(this);
}
}
async bootstrap() {
this.containerService.attachToWindow(window);

View File

@ -54,7 +54,6 @@ export default class BrowserApi {
}
static getBackgroundPage(): any {
function getBackgroundPage(): any {
if (BrowserApi.isChromeApi) {
return chrome.extension.getBackgroundPage();
} else if (BrowserApi.isSafariApi) {
@ -63,5 +62,4 @@ export default class BrowserApi {
return null;
}
}
}
}

View File

@ -11,10 +11,10 @@ export default function i18nService(platformUtilsService: PlatformUtilsService)
'zh-CN', 'zh-TW',
];
async function loadMessages(locale: string, messagesObj: any,
async function loadMessages(localesDir: string, locale: string, messagesObj: any,
messageCallback: (prop: string, message: string) => string): Promise<any> {
const formattedLocale = locale.replace('-', '_');
const file = await fetch('../_locales/' + formattedLocale + '/messages.json');
const file = await fetch(localesDir + formattedLocale + '/messages.json');
const locales = await file.json();
for (const prop in locales) {
if (locales.hasOwnProperty(prop)) {
@ -24,7 +24,7 @@ export default function i18nService(platformUtilsService: PlatformUtilsService)
}
if (platformUtilsService.isEdge()) {
loadMessages('en', localeMessages, (prop: string, message: string) => chrome.i18n.getMessage(prop));
loadMessages('../_locales/', 'en', localeMessages, (prop: string, message: string) => chrome.i18n.getMessage(prop));
return localeMessages;
}
@ -38,9 +38,10 @@ export default function i18nService(platformUtilsService: PlatformUtilsService)
}
}
loadMessages(lang, localeMessages, (prop: string, message: string) => message);
const dir = './_locales/';
loadMessages(dir, lang, localeMessages, (prop: string, message: string) => message);
if (lang !== supportedLocales[0]) {
loadMessages(supportedLocales[0], defaultMessages, (prop: string, message: string) => message);
loadMessages(dir, supportedLocales[0], defaultMessages, (prop: string, message: string) => message);
}
}