import Foundation

enum ContentLanguage: String {

    case english = "en"

    case german = "de"
}

extension ContentLanguage: Codable {
    
}

extension ContentLanguage: CaseIterable {
    
}

extension ContentLanguage: Hashable {

}

extension ContentLanguage: Identifiable {

    var id: String {
        rawValue
    }
}

extension ContentLanguage: Comparable {

    static func < (lhs: ContentLanguage, rhs: ContentLanguage) -> Bool {
        lhs.rawValue < rhs.rawValue
    }
}

extension ContentLanguage: CustomStringConvertible {

    var description: String {
        rawValue
    }
}

extension ContentLanguage {

    func text(days: Int) -> String {
        switch self {
        case .english: return "\(days) day\(days == 1 ? "" : "s")"
        case .german: return "\(days) Tag\(days == 1 ? "" : "e")"
        }
    }

    var locale: Locale {
        switch self {
        case .english: Locale(identifier: "en_US")
        case .german: Locale(identifier: "de_DE")
        }
    }

    var next: ContentLanguage {
        switch self {
        case .english: return .german
        case .german: return .english
        }
    }

    var text: String {
        switch self {
            case .english: return "English"
            case .german: return "German"
        }
    }

    var shortText: String {
        switch self {
            case .english: "EN"
            case .german: "DE"
        }
    }
}
