mirror of
https://github.com/AU-COVIDSafe/mobile-ios.git
synced 2025-04-19 21:15:21 +00:00
COVIDSafe code from version 1.11 (#22)
This commit is contained in:
parent
746841a945
commit
a2b6a8bfb5
65 changed files with 6555 additions and 2216 deletions
|
@ -11,21 +11,21 @@ struct URLHelper {
|
|||
|
||||
static let host = "https://www.covidsafe.gov.au"
|
||||
|
||||
static func getAustralianNumberURL() -> String {
|
||||
return "\(getHelpURL())#verify-mobile-number-pin"
|
||||
}
|
||||
|
||||
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
|
||||
var 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.
|
||||
}
|
||||
if matches.count == 0 {
|
||||
matches = supportedLocales.filter { (supportedLocale) -> Bool in
|
||||
return 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 else {
|
||||
return "en"
|
||||
|
@ -33,17 +33,24 @@ struct URLHelper {
|
|||
return localeCode
|
||||
}
|
||||
|
||||
static func getHelpURL() -> String {
|
||||
static fileprivate func buildLocalisedURL(path: String) -> String {
|
||||
let localeCode = getLocale()
|
||||
guard localeCode != "en" else {
|
||||
return "\(host)/help-topics.html"
|
||||
return "\(host)/\(path).html"
|
||||
}
|
||||
|
||||
return "\(host)/help-topics/\(localeCode.lowercased()).html"
|
||||
return "\(host)/\(path)/\(localeCode.lowercased()).html"
|
||||
}
|
||||
|
||||
static func getHelpURL() -> String {
|
||||
return buildLocalisedURL(path: "help-topics")
|
||||
}
|
||||
|
||||
static func getPrivacyPolicyURL() -> String {
|
||||
return "\(host)/privacy-policy.html"
|
||||
return buildLocalisedURL(path: "privacy-policy")
|
||||
}
|
||||
|
||||
static func getAustralianNumberURL() -> String {
|
||||
return "\(getHelpURL())#verify-mobile-number-pin"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue