Make localizedName a subordinate method
To reuse localizedCountryArea for sorting regardless of display.
This commit is contained in:
parent
42f64db0b7
commit
dacd5653b4
|
@ -74,7 +74,7 @@ public struct Pool: Codable, Comparable, CustomStringConvertible {
|
||||||
// MARK: Comparable
|
// MARK: Comparable
|
||||||
|
|
||||||
public static func <(lhs: Pool, rhs: Pool) -> Bool {
|
public static func <(lhs: Pool, rhs: Pool) -> Bool {
|
||||||
return lhs.localizedName < rhs.localizedName
|
return lhs.localizedCountryArea < rhs.localizedCountryArea
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: CustomStringConvertible
|
// MARK: CustomStringConvertible
|
||||||
|
@ -91,6 +91,14 @@ extension Pool {
|
||||||
return Utils.localizedCountry(country)
|
return Utils.localizedCountry(country)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var localizedCountryArea: String {
|
||||||
|
let countryString = localizedCountry
|
||||||
|
guard let area = area else {
|
||||||
|
return countryString
|
||||||
|
}
|
||||||
|
return String.init(format: Pool.localizedFormat, countryString, area.uppercased())
|
||||||
|
}
|
||||||
|
|
||||||
public var localizedName: String {
|
public var localizedName: String {
|
||||||
|
|
||||||
// // XXX: name from API is not localized
|
// // XXX: name from API is not localized
|
||||||
|
@ -98,11 +106,7 @@ extension Pool {
|
||||||
// return name
|
// return name
|
||||||
// }
|
// }
|
||||||
|
|
||||||
let countryString = localizedCountry
|
return localizedCountryArea
|
||||||
guard let area = area else {
|
// return localizedCountry
|
||||||
return countryString
|
|
||||||
}
|
|
||||||
return String.init(format: Pool.localizedFormat, countryString, area.uppercased())
|
|
||||||
// return countryString
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue