mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-29 17:38:04 +01:00
safari fixes
This commit is contained in:
parent
2b6c2bd4e2
commit
61dc7454d3
@ -142,15 +142,17 @@ export default class MainBackground {
|
||||
opr.sidebarAction : (window as any).chrome.sidebarAction;
|
||||
|
||||
// Background
|
||||
this.commandsBackground = new CommandsBackground(this, this.passwordGenerationService);
|
||||
this.contextMenusBackground = new ContextMenusBackground(this, this.cipherService,
|
||||
this.passwordGenerationService);
|
||||
this.idleBackground = new IdleBackground(this, this.lockService, this.storageService);
|
||||
this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService,
|
||||
this.platformUtilsService);
|
||||
this.tabsBackground = new TabsBackground(this);
|
||||
this.webRequestBackground = new WebRequestBackground(this.platformUtilsService, this.cipherService);
|
||||
this.windowsBackground = new WindowsBackground(this);
|
||||
if (!this.isSafari) {
|
||||
this.commandsBackground = new CommandsBackground(this, this.passwordGenerationService);
|
||||
this.contextMenusBackground = new ContextMenusBackground(this, this.cipherService,
|
||||
this.passwordGenerationService);
|
||||
this.idleBackground = new IdleBackground(this, this.lockService, this.storageService);
|
||||
this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService,
|
||||
this.platformUtilsService);
|
||||
this.tabsBackground = new TabsBackground(this);
|
||||
this.webRequestBackground = new WebRequestBackground(this.platformUtilsService, this.cipherService);
|
||||
this.windowsBackground = new WindowsBackground(this);
|
||||
}
|
||||
}
|
||||
|
||||
async bootstrap() {
|
||||
|
@ -54,14 +54,12 @@ export default class BrowserApi {
|
||||
}
|
||||
|
||||
static getBackgroundPage(): any {
|
||||
function getBackgroundPage(): any {
|
||||
if (BrowserApi.isChromeApi) {
|
||||
return chrome.extension.getBackgroundPage();
|
||||
} else if (BrowserApi.isSafariApi) {
|
||||
return safari.extension.globalPage.contentWindow;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
if (BrowserApi.isChromeApi) {
|
||||
return chrome.extension.getBackgroundPage();
|
||||
} else if (BrowserApi.isSafariApi) {
|
||||
return safari.extension.globalPage.contentWindow;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user