jellyflood/Shared/Extensions/JellyfinAPI/CultureDto.swift

37 lines
940 B
Swift

//
// Swiftfin is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, you can obtain one at https://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2025 Jellyfin & Jellyfin Contributors
//
import Foundation
import JellyfinAPI
extension CultureDto: Displayable {
var displayTitle: String {
if let twoLetterISOLanguageName,
let name = Locale.current.localizedString(forLanguageCode: twoLetterISOLanguageName)
{
return name
}
if let threeLetterISOLanguageNames, let displayName = threeLetterISOLanguageNames
.compactMap({ Locale.current.localizedString(forLanguageCode: $0) })
.first
{
return displayName
}
return displayName ?? L10n.unknown
}
static var none: CultureDto {
CultureDto(
displayName: L10n.none
)
}
}