Fix Pool.localizedId
This commit is contained in:
parent
baf1996f58
commit
94a717befa
|
@ -92,17 +92,23 @@ public struct Pool: Codable, Hashable {
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Pool {
|
extension Pool {
|
||||||
private static let localizedFormat = "%@ - %@"
|
|
||||||
|
|
||||||
public var localizedCountry: String {
|
public var localizedCountry: String {
|
||||||
return Utils.localizedCountry(country)
|
return Utils.localizedCountry(country)
|
||||||
}
|
}
|
||||||
|
|
||||||
public var localizedId: String {
|
public var localizedId: String {
|
||||||
return String.init(format: Pool.localizedFormat, localizedCountry, secondaryId)
|
var comps: [String] = [localizedCountry]
|
||||||
|
if let secondaryId = optionalSecondaryId {
|
||||||
|
comps.append(secondaryId)
|
||||||
|
}
|
||||||
|
return comps.joined(separator: " - ")
|
||||||
}
|
}
|
||||||
|
|
||||||
public var secondaryId: String {
|
public var secondaryId: String {
|
||||||
|
return optionalSecondaryId ?? ""
|
||||||
|
}
|
||||||
|
|
||||||
|
private var optionalSecondaryId: String? {
|
||||||
var comps: [String] = []
|
var comps: [String] = []
|
||||||
if let extraCountries = extraCountries {
|
if let extraCountries = extraCountries {
|
||||||
comps.append(contentsOf: extraCountries.map { Utils.localizedCountry($0) })
|
comps.append(contentsOf: extraCountries.map { Utils.localizedCountry($0) })
|
||||||
|
@ -113,6 +119,9 @@ extension Pool {
|
||||||
if let num = num {
|
if let num = num {
|
||||||
comps.append("#\(num)")
|
comps.append("#\(num)")
|
||||||
}
|
}
|
||||||
|
guard !comps.isEmpty else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
var str = comps.joined(separator: " ")
|
var str = comps.joined(separator: " ")
|
||||||
if let tags = tags {
|
if let tags = tags {
|
||||||
let suffix = tags.map { $0.uppercased() }.joined(separator: ",")
|
let suffix = tags.map { $0.uppercased() }.joined(separator: ",")
|
||||||
|
|
Loading…
Reference in New Issue