opcotech/elemo

View on GitHub
internal/model/language.go

Summary

Maintainability
A
0 mins
Test Coverage
package model

const (
    LanguageAA Language = iota + 1 // ISO Language code of Afar
    LanguageAB                     // ISO Language code of Abkhazian
    LanguageAE                     // ISO Language code of Avestan
    LanguageAF                     // ISO Language code of Afrikaans
    LanguageAK                     // ISO Language code of Akan
    LanguageAM                     // ISO Language code of Amharic
    LanguageAN                     // ISO Language code of Aragonese
    LanguageAR                     // ISO Language code of Arabic
    LanguageAS                     // ISO Language code of Assamese
    LanguageAV                     // ISO Language code of Avaric
    LanguageAY                     // ISO Language code of Aymara
    LanguageAZ                     // ISO Language code of Azerbaijani
    LanguageBA                     // ISO Language code of Bashkir
    LanguageBE                     // ISO Language code of Belarusian
    LanguageBG                     // ISO Language code of Bulgarian
    LanguageBH                     // ISO Language code of Bihari Languages
    LanguageBI                     // ISO Language code of Bislama
    LanguageBM                     // ISO Language code of Bambara
    LanguageBN                     // ISO Language code of Bengali
    LanguageBO                     // ISO Language code of Tibetan
    LanguageBR                     // ISO Language code of Breton
    LanguageBS                     // ISO Language code of Bosnian
    LanguageCA                     // ISO Language code of Catalan
    LanguageCE                     // ISO Language code of Chechen
    LanguageCH                     // ISO Language code of Chamorro
    LanguageCO                     // ISO Language code of Corsican
    LanguageCR                     // ISO Language code of Cree
    LanguageCS                     // ISO Language code of Czech
    LanguageCU                     // ISO Language code of Church Slavic
    LanguageCV                     // ISO Language code of Chuvash
    LanguageCY                     // ISO Language code of Welsh
    LanguageDA                     // ISO Language code of Danish
    LanguageDE                     // ISO Language code of German
    LanguageDV                     // ISO Language code of Divehi
    LanguageDZ                     // ISO Language code of Dzongkha
    LanguageEE                     // ISO Language code of Ewe
    LanguageEL                     // ISO Language code of Greek
    LanguageEN                     // ISO Language code of English
    LanguageEO                     // ISO Language code of Esperanto
    LanguageES                     // ISO Language code of Spanish
    LanguageET                     // ISO Language code of Estonian
    LanguageEU                     // ISO Language code of Basque
    LanguageFA                     // ISO Language code of Persian
    LanguageFF                     // ISO Language code of Fulah
    LanguageFI                     // ISO Language code of Finnish
    LanguageFJ                     // ISO Language code of Fijian
    LanguageFO                     // ISO Language code of Faroese
    LanguageFR                     // ISO Language code of French
    LanguageFY                     // ISO Language code of Western Frisian
    LanguageGA                     // ISO Language code of Irish
    LanguageGD                     // ISO Language code of Gaelic
    LanguageGL                     // ISO Language code of Galician
    LanguageGN                     // ISO Language code of Guarani
    LanguageGU                     // ISO Language code of Gujarati
    LanguageGV                     // ISO Language code of Manx
    LanguageHA                     // ISO Language code of Hausa
    LanguageHE                     // ISO Language code of Hebrew
    LanguageHI                     // ISO Language code of Hindi
    LanguageHO                     // ISO Language code of Hiri Motu
    LanguageHR                     // ISO Language code of Croatian
    LanguageHT                     // ISO Language code of Haitian
    LanguageHU                     // ISO Language code of Hungarian
    LanguageHY                     // ISO Language code of Armenian
    LanguageHZ                     // ISO Language code of Herero
    LanguageIA                     // ISO Language code of Interlingua
    LanguageID                     // ISO Language code of Indonesian
    LanguageIE                     // ISO Language code of Interlingue
    LanguageIG                     // ISO Language code of Igbo
    LanguageII                     // ISO Language code of Sichuan Yi
    LanguageIK                     // ISO Language code of Inupiaq
    LanguageIO                     // ISO Language code of Ido
    LanguageIS                     // ISO Language code of Icelandic
    LanguageIT                     // ISO Language code of Italian
    LanguageIU                     // ISO Language code of Inuktitut
    LanguageJA                     // ISO Language code of Japanese
    LanguageJV                     // ISO Language code of Javanese
    LanguageKA                     // ISO Language code of Georgian
    LanguageKG                     // ISO Language code of Kongo
    LanguageKI                     // ISO Language code of Kikuyu
    LanguageKJ                     // ISO Language code of Kuanyama
    LanguageKK                     // ISO Language code of Kazakh
    LanguageKL                     // ISO Language code of Kalaallisut
    LanguageKM                     // ISO Language code of Central Khmer
    LanguageKN                     // ISO Language code of Kannada
    LanguageKO                     // ISO Language code of Korean
    LanguageKR                     // ISO Language code of Kanuri
    LanguageKS                     // ISO Language code of Kashmiri
    LanguageKU                     // ISO Language code of Kurdish
    LanguageKV                     // ISO Language code of Komi
    LanguageKW                     // ISO Language code of Cornish
    LanguageKY                     // ISO Language code of Kirghiz
    LanguageLA                     // ISO Language code of Latin
    LanguageLB                     // ISO Language code of Luxembourgish
    LanguageLG                     // ISO Language code of Ganda
    LanguageLI                     // ISO Language code of Limburgan
    LanguageLN                     // ISO Language code of Lingala
    LanguageLO                     // ISO Language code of Lao
    LanguageLT                     // ISO Language code of Lithuanian
    LanguageLU                     // ISO Language code of Luba-Katanga
    LanguageLV                     // ISO Language code of Latvian
    LanguageMG                     // ISO Language code of Malagasy
    LanguageMH                     // ISO Language code of Marshallese
    LanguageMI                     // ISO Language code of Maori
    LanguageMK                     // ISO Language code of Macedonian
    LanguageML                     // ISO Language code of Malayalam
    LanguageMN                     // ISO Language code of Mongolian
    LanguageMR                     // ISO Language code of Marathi
    LanguageMS                     // ISO Language code of Malay
    LanguageMT                     // ISO Language code of Maltese
    LanguageMY                     // ISO Language code of Burmese
    LanguageNA                     // ISO Language code of Nauru
    LanguageNB                     // ISO Language code of Norwegian Bokmål
    LanguageND                     // ISO Language code of North Ndebele
    LanguageNE                     // ISO Language code of Nepali
    LanguageNG                     // ISO Language code of Ndonga
    LanguageNL                     // ISO Language code of Dutch; Flemish
    LanguageNN                     // ISO Language code of Norwegian Nynorsk
    LanguageNO                     // ISO Language code of Norwegian
    LanguageNR                     // ISO Language code of South Ndebele
    LanguageNV                     // ISO Language code of Navajo
    LanguageNY                     // ISO Language code of Chichewa
    LanguageOC                     // ISO Language code of Occitan
    LanguageOJ                     // ISO Language code of Ojibwa
    LanguageOM                     // ISO Language code of Oromo
    LanguageOR                     // ISO Language code of Oriya
    LanguageOS                     // ISO Language code of Ossetian
    LanguagePA                     // ISO Language code of Panjabi
    LanguagePI                     // ISO Language code of Pali
    LanguagePL                     // ISO Language code of Polish
    LanguagePS                     // ISO Language code of Pushto
    LanguagePT                     // ISO Language code of Portuguese
    LanguageQU                     // ISO Language code of Quechua
    LanguageRM                     // ISO Language code of Romansh
    LanguageRN                     // ISO Language code of Rundi
    LanguageRO                     // ISO Language code of Romanian
    LanguageRU                     // ISO Language code of Russian
    LanguageRW                     // ISO Language code of Kinyarwanda
    LanguageSA                     // ISO Language code of Sanskrit
    LanguageSC                     // ISO Language code of Sardinian
    LanguageSD                     // ISO Language code of Sindhi
    LanguageSE                     // ISO Language code of Northern Sami
    LanguageSG                     // ISO Language code of Sango
    LanguageSI                     // ISO Language code of Sinhala; Sinhalese
    LanguageSK                     // ISO Language code of Slovak
    LanguageSL                     // ISO Language code of Slovenian
    LanguageSM                     // ISO Language code of Samoan
    LanguageSN                     // ISO Language code of Shona
    LanguageSO                     // ISO Language code of Somali
    LanguageSQ                     // ISO Language code of Albanian
    LanguageSR                     // ISO Language code of Serbian
    LanguageSS                     // ISO Language code of Swati
    LanguageST                     // ISO Language code of Sotho
    LanguageSU                     // ISO Language code of Sundanese
    LanguageSV                     // ISO Language code of Swedish
    LanguageSW                     // ISO Language code of Swahili
    LanguageTA                     // ISO Language code of Tamil
    LanguageTE                     // ISO Language code of Telugu
    LanguageTG                     // ISO Language code of Tajik
    LanguageTH                     // ISO Language code of Thai
    LanguageTI                     // ISO Language code of Tigrinya
    LanguageTK                     // ISO Language code of Turkmen
    LanguageTL                     // ISO Language code of Tagalog
    LanguageTN                     // ISO Language code of Tswana
    LanguageTO                     // ISO Language code of Tonga
    LanguageTR                     // ISO Language code of Turkish
    LanguageTS                     // ISO Language code of Tsonga
    LanguageTT                     // ISO Language code of Tatar
    LanguageTW                     // ISO Language code of Twi
    LanguageTY                     // ISO Language code of Tahitian
    LanguageUG                     // ISO Language code of Uighur
    LanguageUK                     // ISO Language code of Ukrainian
    LanguageUR                     // ISO Language code of Urdu
    LanguageUZ                     // ISO Language code of Uzbek
    LanguageVE                     // ISO Language code of Venda
    LanguageVI                     // ISO Language code of Vietnamese
    LanguageVO                     // ISO Language code of Volapük
    LanguageWA                     // ISO Language code of Walloon
    LanguageWO                     // ISO Language code of Wolof
    LanguageXH                     // ISO Language code of Xhosa
    LanguageYI                     // ISO Language code of Yiddish
    LanguageYO                     // ISO Language code of Yoruba
    LanguageZA                     // ISO Language code of Zhuang
    LanguageZH                     // ISO Language code of Chinese
    LanguageZU                     // ISO Language code of Zulu
)

var (
    languageCodeKeys = map[string]Language{
        "aa": LanguageAA,
        "ab": LanguageAB,
        "ae": LanguageAE,
        "af": LanguageAF,
        "ak": LanguageAK,
        "am": LanguageAM,
        "an": LanguageAN,
        "ar": LanguageAR,
        "as": LanguageAS,
        "av": LanguageAV,
        "ay": LanguageAY,
        "az": LanguageAZ,
        "ba": LanguageBA,
        "be": LanguageBE,
        "bg": LanguageBG,
        "bh": LanguageBH,
        "bi": LanguageBI,
        "bm": LanguageBM,
        "bn": LanguageBN,
        "bo": LanguageBO,
        "br": LanguageBR,
        "bs": LanguageBS,
        "ca": LanguageCA,
        "ce": LanguageCE,
        "ch": LanguageCH,
        "co": LanguageCO,
        "cr": LanguageCR,
        "cs": LanguageCS,
        "cu": LanguageCU,
        "cv": LanguageCV,
        "cy": LanguageCY,
        "da": LanguageDA,
        "de": LanguageDE,
        "dv": LanguageDV,
        "dz": LanguageDZ,
        "ee": LanguageEE,
        "el": LanguageEL,
        "en": LanguageEN,
        "eo": LanguageEO,
        "es": LanguageES,
        "et": LanguageET,
        "eu": LanguageEU,
        "fa": LanguageFA,
        "ff": LanguageFF,
        "fi": LanguageFI,
        "fj": LanguageFJ,
        "fo": LanguageFO,
        "fr": LanguageFR,
        "fy": LanguageFY,
        "ga": LanguageGA,
        "gd": LanguageGD,
        "gl": LanguageGL,
        "gn": LanguageGN,
        "gu": LanguageGU,
        "gv": LanguageGV,
        "ha": LanguageHA,
        "he": LanguageHE,
        "hi": LanguageHI,
        "ho": LanguageHO,
        "hr": LanguageHR,
        "ht": LanguageHT,
        "hu": LanguageHU,
        "hy": LanguageHY,
        "hz": LanguageHZ,
        "ia": LanguageIA,
        "id": LanguageID,
        "ie": LanguageIE,
        "ig": LanguageIG,
        "ii": LanguageII,
        "ik": LanguageIK,
        "io": LanguageIO,
        "is": LanguageIS,
        "it": LanguageIT,
        "iu": LanguageIU,
        "ja": LanguageJA,
        "jv": LanguageJV,
        "ka": LanguageKA,
        "kg": LanguageKG,
        "ki": LanguageKI,
        "kj": LanguageKJ,
        "kk": LanguageKK,
        "kl": LanguageKL,
        "km": LanguageKM,
        "kn": LanguageKN,
        "ko": LanguageKO,
        "kr": LanguageKR,
        "ks": LanguageKS,
        "ku": LanguageKU,
        "kv": LanguageKV,
        "kw": LanguageKW,
        "ky": LanguageKY,
        "la": LanguageLA,
        "lb": LanguageLB,
        "lg": LanguageLG,
        "li": LanguageLI,
        "ln": LanguageLN,
        "lo": LanguageLO,
        "lt": LanguageLT,
        "lu": LanguageLU,
        "lv": LanguageLV,
        "mg": LanguageMG,
        "mh": LanguageMH,
        "mi": LanguageMI,
        "mk": LanguageMK,
        "ml": LanguageML,
        "mn": LanguageMN,
        "mr": LanguageMR,
        "ms": LanguageMS,
        "mt": LanguageMT,
        "my": LanguageMY,
        "na": LanguageNA,
        "nb": LanguageNB,
        "nd": LanguageND,
        "ne": LanguageNE,
        "ng": LanguageNG,
        "nl": LanguageNL,
        "nn": LanguageNN,
        "no": LanguageNO,
        "nr": LanguageNR,
        "nv": LanguageNV,
        "ny": LanguageNY,
        "oc": LanguageOC,
        "oj": LanguageOJ,
        "om": LanguageOM,
        "or": LanguageOR,
        "os": LanguageOS,
        "pa": LanguagePA,
        "pi": LanguagePI,
        "pl": LanguagePL,
        "ps": LanguagePS,
        "pt": LanguagePT,
        "qu": LanguageQU,
        "rm": LanguageRM,
        "rn": LanguageRN,
        "ro": LanguageRO,
        "ru": LanguageRU,
        "rw": LanguageRW,
        "sa": LanguageSA,
        "sc": LanguageSC,
        "sd": LanguageSD,
        "se": LanguageSE,
        "sg": LanguageSG,
        "si": LanguageSI,
        "sk": LanguageSK,
        "sl": LanguageSL,
        "sm": LanguageSM,
        "sn": LanguageSN,
        "so": LanguageSO,
        "sq": LanguageSQ,
        "sr": LanguageSR,
        "ss": LanguageSS,
        "st": LanguageST,
        "su": LanguageSU,
        "sv": LanguageSV,
        "sw": LanguageSW,
        "ta": LanguageTA,
        "te": LanguageTE,
        "tg": LanguageTG,
        "th": LanguageTH,
        "ti": LanguageTI,
        "tk": LanguageTK,
        "tl": LanguageTL,
        "tn": LanguageTN,
        "to": LanguageTO,
        "tr": LanguageTR,
        "ts": LanguageTS,
        "tt": LanguageTT,
        "tw": LanguageTW,
        "ty": LanguageTY,
        "ug": LanguageUG,
        "uk": LanguageUK,
        "ur": LanguageUR,
        "uz": LanguageUZ,
        "ve": LanguageVE,
        "vi": LanguageVI,
        "vo": LanguageVO,
        "wa": LanguageWA,
        "wo": LanguageWO,
        "xh": LanguageXH,
        "yi": LanguageYI,
        "yo": LanguageYO,
        "za": LanguageZA,
        "zh": LanguageZH,
        "zu": LanguageZU,
    }
    languageCodeValues = map[Language]string{
        LanguageAA: "aa",
        LanguageAB: "ab",
        LanguageAE: "ae",
        LanguageAF: "af",
        LanguageAK: "ak",
        LanguageAM: "am",
        LanguageAN: "an",
        LanguageAR: "ar",
        LanguageAS: "as",
        LanguageAV: "av",
        LanguageAY: "ay",
        LanguageAZ: "az",
        LanguageBA: "ba",
        LanguageBE: "be",
        LanguageBG: "bg",
        LanguageBH: "bh",
        LanguageBI: "bi",
        LanguageBM: "bm",
        LanguageBN: "bn",
        LanguageBO: "bo",
        LanguageBR: "br",
        LanguageBS: "bs",
        LanguageCA: "ca",
        LanguageCE: "ce",
        LanguageCH: "ch",
        LanguageCO: "co",
        LanguageCR: "cr",
        LanguageCS: "cs",
        LanguageCU: "cu",
        LanguageCV: "cv",
        LanguageCY: "cy",
        LanguageDA: "da",
        LanguageDE: "de",
        LanguageDV: "dv",
        LanguageDZ: "dz",
        LanguageEE: "ee",
        LanguageEL: "el",
        LanguageEN: "en",
        LanguageEO: "eo",
        LanguageES: "es",
        LanguageET: "et",
        LanguageEU: "eu",
        LanguageFA: "fa",
        LanguageFF: "ff",
        LanguageFI: "fi",
        LanguageFJ: "fj",
        LanguageFO: "fo",
        LanguageFR: "fr",
        LanguageFY: "fy",
        LanguageGA: "ga",
        LanguageGD: "gd",
        LanguageGL: "gl",
        LanguageGN: "gn",
        LanguageGU: "gu",
        LanguageGV: "gv",
        LanguageHA: "ha",
        LanguageHE: "he",
        LanguageHI: "hi",
        LanguageHO: "ho",
        LanguageHR: "hr",
        LanguageHT: "ht",
        LanguageHU: "hu",
        LanguageHY: "hy",
        LanguageHZ: "hz",
        LanguageIA: "ia",
        LanguageID: "id",
        LanguageIE: "ie",
        LanguageIG: "ig",
        LanguageII: "ii",
        LanguageIK: "ik",
        LanguageIO: "io",
        LanguageIS: "is",
        LanguageIT: "it",
        LanguageIU: "iu",
        LanguageJA: "ja",
        LanguageJV: "jv",
        LanguageKA: "ka",
        LanguageKG: "kg",
        LanguageKI: "ki",
        LanguageKJ: "kj",
        LanguageKK: "kk",
        LanguageKL: "kl",
        LanguageKM: "km",
        LanguageKN: "kn",
        LanguageKO: "ko",
        LanguageKR: "kr",
        LanguageKS: "ks",
        LanguageKU: "ku",
        LanguageKV: "kv",
        LanguageKW: "kw",
        LanguageKY: "ky",
        LanguageLA: "la",
        LanguageLB: "lb",
        LanguageLG: "lg",
        LanguageLI: "li",
        LanguageLN: "ln",
        LanguageLO: "lo",
        LanguageLT: "lt",
        LanguageLU: "lu",
        LanguageLV: "lv",
        LanguageMG: "mg",
        LanguageMH: "mh",
        LanguageMI: "mi",
        LanguageMK: "mk",
        LanguageML: "ml",
        LanguageMN: "mn",
        LanguageMR: "mr",
        LanguageMS: "ms",
        LanguageMT: "mt",
        LanguageMY: "my",
        LanguageNA: "na",
        LanguageNB: "nb",
        LanguageND: "nd",
        LanguageNE: "ne",
        LanguageNG: "ng",
        LanguageNL: "nl",
        LanguageNN: "nn",
        LanguageNO: "no",
        LanguageNR: "nr",
        LanguageNV: "nv",
        LanguageNY: "ny",
        LanguageOC: "oc",
        LanguageOJ: "oj",
        LanguageOM: "om",
        LanguageOR: "or",
        LanguageOS: "os",
        LanguagePA: "pa",
        LanguagePI: "pi",
        LanguagePL: "pl",
        LanguagePS: "ps",
        LanguagePT: "pt",
        LanguageQU: "qu",
        LanguageRM: "rm",
        LanguageRN: "rn",
        LanguageRO: "ro",
        LanguageRU: "ru",
        LanguageRW: "rw",
        LanguageSA: "sa",
        LanguageSC: "sc",
        LanguageSD: "sd",
        LanguageSE: "se",
        LanguageSG: "sg",
        LanguageSI: "si",
        LanguageSK: "sk",
        LanguageSL: "sl",
        LanguageSM: "sm",
        LanguageSN: "sn",
        LanguageSO: "so",
        LanguageSQ: "sq",
        LanguageSR: "sr",
        LanguageSS: "ss",
        LanguageST: "st",
        LanguageSU: "su",
        LanguageSV: "sv",
        LanguageSW: "sw",
        LanguageTA: "ta",
        LanguageTE: "te",
        LanguageTG: "tg",
        LanguageTH: "th",
        LanguageTI: "ti",
        LanguageTK: "tk",
        LanguageTL: "tl",
        LanguageTN: "tn",
        LanguageTO: "to",
        LanguageTR: "tr",
        LanguageTS: "ts",
        LanguageTT: "tt",
        LanguageTW: "tw",
        LanguageTY: "ty",
        LanguageUG: "ug",
        LanguageUK: "uk",
        LanguageUR: "ur",
        LanguageUZ: "uz",
        LanguageVE: "ve",
        LanguageVI: "vi",
        LanguageVO: "vo",
        LanguageWA: "wa",
        LanguageWO: "wo",
        LanguageXH: "xh",
        LanguageYI: "yi",
        LanguageYO: "yo",
        LanguageZA: "za",
        LanguageZH: "zh",
        LanguageZU: "zu",
    }
)

// Language represents a Language ISO code.
type Language uint8

// String returns the string representation of the Language code.
func (l Language) String() string {
    return languageCodeValues[l]
}

// MarshalText implements the encoding.TextMarshaler interface.
func (l Language) MarshalText() (text []byte, err error) {
    if l < LanguageAA || l > LanguageZU {
        return nil, ErrInvalidLanguage
    }
    return []byte(l.String()), nil
}

// UnmarshalText implements the encoding.TextUnmarshaler interface.
func (l *Language) UnmarshalText(text []byte) error {
    if v, ok := languageCodeKeys[string(text)]; ok {
        *l = v
        return nil
    }
    return ErrInvalidLanguage
}