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,15 +142,17 @@ export default class MainBackground {
opr.sidebarAction : (window as any).chrome.sidebarAction; opr.sidebarAction : (window as any).chrome.sidebarAction;
// Background // Background
this.commandsBackground = new CommandsBackground(this, this.passwordGenerationService); if (!this.isSafari) {
this.contextMenusBackground = new ContextMenusBackground(this, this.cipherService, this.commandsBackground = new CommandsBackground(this, this.passwordGenerationService);
this.passwordGenerationService); this.contextMenusBackground = new ContextMenusBackground(this, this.cipherService,
this.idleBackground = new IdleBackground(this, this.lockService, this.storageService); this.passwordGenerationService);
this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService, this.idleBackground = new IdleBackground(this, this.lockService, this.storageService);
this.platformUtilsService); this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService,
this.tabsBackground = new TabsBackground(this); this.platformUtilsService);
this.webRequestBackground = new WebRequestBackground(this.platformUtilsService, this.cipherService); this.tabsBackground = new TabsBackground(this);
this.windowsBackground = new WindowsBackground(this); this.webRequestBackground = new WebRequestBackground(this.platformUtilsService, this.cipherService);
this.windowsBackground = new WindowsBackground(this);
}
} }
async bootstrap() { async bootstrap() {

View File

@ -54,14 +54,12 @@ export default class BrowserApi {
} }
static getBackgroundPage(): any { static getBackgroundPage(): any {
function getBackgroundPage(): any { if (BrowserApi.isChromeApi) {
if (BrowserApi.isChromeApi) { return chrome.extension.getBackgroundPage();
return chrome.extension.getBackgroundPage(); } else if (BrowserApi.isSafariApi) {
} else if (BrowserApi.isSafariApi) { return safari.extension.globalPage.contentWindow;
return safari.extension.globalPage.contentWindow; } else {
} else { return null;
return null;
}
} }
} }
} }

View File

@ -11,10 +11,10 @@ export default function i18nService(platformUtilsService: PlatformUtilsService)
'zh-CN', 'zh-TW', '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> { messageCallback: (prop: string, message: string) => string): Promise<any> {
const formattedLocale = locale.replace('-', '_'); 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(); const locales = await file.json();
for (const prop in locales) { for (const prop in locales) {
if (locales.hasOwnProperty(prop)) { if (locales.hasOwnProperty(prop)) {
@ -24,7 +24,7 @@ export default function i18nService(platformUtilsService: PlatformUtilsService)
} }
if (platformUtilsService.isEdge()) { 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; 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]) { if (lang !== supportedLocales[0]) {
loadMessages(supportedLocales[0], defaultMessages, (prop: string, message: string) => message); loadMessages(dir, supportedLocales[0], defaultMessages, (prop: string, message: string) => message);
} }
} }