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

get locale strings command to swift app

This commit is contained in:
Kyle Spearrin 2019-08-14 16:46:19 -04:00
parent 68593e9df2
commit 406525223d

View File

@ -76,6 +76,19 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe
UserDefaults.standard.removeObject(forKey: m!.data!)
m!.data = nil
replyMessage(message: m!)
} else if(command == "getLocaleStrings") {
let language = String(describing: m!.data)
m!.data = nil
if let path = Bundle.main.path(forResource: "app/_locales/\(language)/messages", ofType: "json") {
do {
let data = try Data(contentsOf: URL(fileURLWithPath: path), options: .alwaysMapped)
let json = String(data: data, encoding: .utf8)
m!.data = json
} catch {
}
}
replyMessage(message: m!)
}
}
}