mirror of
https://github.com/AU-COVIDSafe/mobile-ios.git
synced 2025-04-19 21:15:21 +00:00
COVIDSafe code from version 1.1
This commit is contained in:
commit
3640e52eb2
330 changed files with 261540 additions and 0 deletions
31
CovidSafe/Feedback/Sources/LanguageInfoExtension.swift
Normal file
31
CovidSafe/Feedback/Sources/LanguageInfoExtension.swift
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Copyright © 2020 Australian Government All rights reserved.
|
||||
|
||||
import Foundation
|
||||
|
||||
extension NSLocale {
|
||||
class var languageDisplayNameOrNil: String? {
|
||||
// Consider going to NSBundle preferredLocalizations to get language the user is actually seeing in the running app.
|
||||
guard let languageCode = preferredLanguages[safe: 0] else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return current.localizedString(forLanguageCode: languageCode)
|
||||
}
|
||||
|
||||
class var preferredLanguageDisplayName: String? {
|
||||
guard let languageDisplayName = languageDisplayNameOrNil else {
|
||||
return nil
|
||||
}
|
||||
return languageDisplayName
|
||||
}
|
||||
|
||||
class var infoAsDictionary: [String: NSObject] {
|
||||
return ["language": preferredLanguageDisplayName as NSObject? ?? "" as NSObject]
|
||||
}
|
||||
}
|
||||
|
||||
extension Array {
|
||||
fileprivate subscript (safe index: UInt) -> Element? {
|
||||
return Int(index) < count ? self[Int(index)] : nil
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue