1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-23 11:56:00 +01:00

fix language locale loading

This commit is contained in:
Kyle Spearrin 2019-08-19 15:42:58 -04:00
parent b30d4b7f4d
commit c041fd7504

View File

@ -75,9 +75,9 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
UserDefaults.standard.removeObject(forKey: m!.data!) UserDefaults.standard.removeObject(forKey: m!.data!)
replyMessage(message: m!) replyMessage(message: m!)
} else if command == "getLocaleStrings" { } else if command == "getLocaleStrings" {
let language = m!.data let language = m!.data ?? "en"
let bundleURL = Bundle.main.resourceURL!.absoluteURL let bundleURL = Bundle.main.resourceURL!.absoluteURL
let messagesUrl = bundleURL.appendingPathComponent("app/_locales/en/messages.json") let messagesUrl = bundleURL.appendingPathComponent("app/_locales/\(language)/messages.json")
do { do {
let json = try String(contentsOf: messagesUrl, encoding: .utf8) let json = try String(contentsOf: messagesUrl, encoding: .utf8)
webView.evaluateJavaScript("window.bitwardenLocaleStrings = \(json);", completionHandler: nil) webView.evaluateJavaScript("window.bitwardenLocaleStrings = \(json);", completionHandler: nil)