COVIDSafe code from version 1.10

This commit is contained in:
covidsafe-support 2020-08-18 10:49:31 +10:00
parent 3b1d8fa3f4
commit 9d9164c615
37 changed files with 2681 additions and 328 deletions

View file

@ -8,20 +8,42 @@
import Foundation
struct URLHelper {
static let host = "https://www.covidsafe.gov.au"
static func getAustralianNumberURL() -> String {
return "\(getHelpURL())#verify-mobile-number-pin"
}
static func getHelpURL() -> String {
private static func getLocale() -> String {
guard let langCode = Locale.current.languageCode else {
return "en"
}
let localeId = Locale.current.identifier
let supportedLocales = Bundle.main.localizations
let matches = supportedLocales.filter { (supportedLocale) -> Bool in
return localeId.starts(with: supportedLocale)
|| supportedLocale.starts(with: "\(langCode)-") // for punjabi is particularly special that the identifier is pa_AU although
// the language code in the supported locals is pa-IN.
// just checking it has the pa- should be enough. I anticipate this happening in other dialects as they come.
}
guard let localeCode = matches.first, localeCode != "en" else {
return "https://www.covidsafe.gov.au/help-topics.html"
guard let localeCode = matches.first else {
return "en"
}
return localeCode
}
static func getHelpURL() -> String {
let localeCode = getLocale()
guard localeCode != "en" else {
return "\(host)/help-topics.html"
}
return "https://www.covidsafe.gov.au/help-topics/\(localeCode.lowercased()).html"
return "\(host)/help-topics/\(localeCode.lowercased()).html"
}
static func getPrivacyPolicyURL() -> String {
return "\(host)/privacy-policy.html"
}
}