William Kurkian | ea86948 | 2019-04-09 15:16:11 -0400 | [diff] [blame] | 1 | // Copyright 2013 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package language |
| 6 | |
| 7 | // TODO: Various sets of commonly use tags and regions. |
| 8 | |
| 9 | // MustParse is like Parse, but panics if the given BCP 47 tag cannot be parsed. |
| 10 | // It simplifies safe initialization of Tag values. |
| 11 | func MustParse(s string) Tag { |
| 12 | t, err := Parse(s) |
| 13 | if err != nil { |
| 14 | panic(err) |
| 15 | } |
| 16 | return t |
| 17 | } |
| 18 | |
| 19 | // MustParse is like Parse, but panics if the given BCP 47 tag cannot be parsed. |
| 20 | // It simplifies safe initialization of Tag values. |
| 21 | func (c CanonType) MustParse(s string) Tag { |
| 22 | t, err := c.Parse(s) |
| 23 | if err != nil { |
| 24 | panic(err) |
| 25 | } |
| 26 | return t |
| 27 | } |
| 28 | |
| 29 | // MustParseBase is like ParseBase, but panics if the given base cannot be parsed. |
| 30 | // It simplifies safe initialization of Base values. |
| 31 | func MustParseBase(s string) Base { |
| 32 | b, err := ParseBase(s) |
| 33 | if err != nil { |
| 34 | panic(err) |
| 35 | } |
| 36 | return b |
| 37 | } |
| 38 | |
| 39 | // MustParseScript is like ParseScript, but panics if the given script cannot be |
| 40 | // parsed. It simplifies safe initialization of Script values. |
| 41 | func MustParseScript(s string) Script { |
| 42 | scr, err := ParseScript(s) |
| 43 | if err != nil { |
| 44 | panic(err) |
| 45 | } |
| 46 | return scr |
| 47 | } |
| 48 | |
| 49 | // MustParseRegion is like ParseRegion, but panics if the given region cannot be |
| 50 | // parsed. It simplifies safe initialization of Region values. |
| 51 | func MustParseRegion(s string) Region { |
| 52 | r, err := ParseRegion(s) |
| 53 | if err != nil { |
| 54 | panic(err) |
| 55 | } |
| 56 | return r |
| 57 | } |
| 58 | |
| 59 | var ( |
| 60 | und = Tag{} |
| 61 | |
| 62 | Und Tag = Tag{} |
| 63 | |
| 64 | Afrikaans Tag = Tag{lang: _af} // af |
| 65 | Amharic Tag = Tag{lang: _am} // am |
| 66 | Arabic Tag = Tag{lang: _ar} // ar |
| 67 | ModernStandardArabic Tag = Tag{lang: _ar, region: _001} // ar-001 |
| 68 | Azerbaijani Tag = Tag{lang: _az} // az |
| 69 | Bulgarian Tag = Tag{lang: _bg} // bg |
| 70 | Bengali Tag = Tag{lang: _bn} // bn |
| 71 | Catalan Tag = Tag{lang: _ca} // ca |
| 72 | Czech Tag = Tag{lang: _cs} // cs |
| 73 | Danish Tag = Tag{lang: _da} // da |
| 74 | German Tag = Tag{lang: _de} // de |
| 75 | Greek Tag = Tag{lang: _el} // el |
| 76 | English Tag = Tag{lang: _en} // en |
| 77 | AmericanEnglish Tag = Tag{lang: _en, region: _US} // en-US |
| 78 | BritishEnglish Tag = Tag{lang: _en, region: _GB} // en-GB |
| 79 | Spanish Tag = Tag{lang: _es} // es |
| 80 | EuropeanSpanish Tag = Tag{lang: _es, region: _ES} // es-ES |
| 81 | LatinAmericanSpanish Tag = Tag{lang: _es, region: _419} // es-419 |
| 82 | Estonian Tag = Tag{lang: _et} // et |
| 83 | Persian Tag = Tag{lang: _fa} // fa |
| 84 | Finnish Tag = Tag{lang: _fi} // fi |
| 85 | Filipino Tag = Tag{lang: _fil} // fil |
| 86 | French Tag = Tag{lang: _fr} // fr |
| 87 | CanadianFrench Tag = Tag{lang: _fr, region: _CA} // fr-CA |
| 88 | Gujarati Tag = Tag{lang: _gu} // gu |
| 89 | Hebrew Tag = Tag{lang: _he} // he |
| 90 | Hindi Tag = Tag{lang: _hi} // hi |
| 91 | Croatian Tag = Tag{lang: _hr} // hr |
| 92 | Hungarian Tag = Tag{lang: _hu} // hu |
| 93 | Armenian Tag = Tag{lang: _hy} // hy |
| 94 | Indonesian Tag = Tag{lang: _id} // id |
| 95 | Icelandic Tag = Tag{lang: _is} // is |
| 96 | Italian Tag = Tag{lang: _it} // it |
| 97 | Japanese Tag = Tag{lang: _ja} // ja |
| 98 | Georgian Tag = Tag{lang: _ka} // ka |
| 99 | Kazakh Tag = Tag{lang: _kk} // kk |
| 100 | Khmer Tag = Tag{lang: _km} // km |
| 101 | Kannada Tag = Tag{lang: _kn} // kn |
| 102 | Korean Tag = Tag{lang: _ko} // ko |
| 103 | Kirghiz Tag = Tag{lang: _ky} // ky |
| 104 | Lao Tag = Tag{lang: _lo} // lo |
| 105 | Lithuanian Tag = Tag{lang: _lt} // lt |
| 106 | Latvian Tag = Tag{lang: _lv} // lv |
| 107 | Macedonian Tag = Tag{lang: _mk} // mk |
| 108 | Malayalam Tag = Tag{lang: _ml} // ml |
| 109 | Mongolian Tag = Tag{lang: _mn} // mn |
| 110 | Marathi Tag = Tag{lang: _mr} // mr |
| 111 | Malay Tag = Tag{lang: _ms} // ms |
| 112 | Burmese Tag = Tag{lang: _my} // my |
| 113 | Nepali Tag = Tag{lang: _ne} // ne |
| 114 | Dutch Tag = Tag{lang: _nl} // nl |
| 115 | Norwegian Tag = Tag{lang: _no} // no |
| 116 | Punjabi Tag = Tag{lang: _pa} // pa |
| 117 | Polish Tag = Tag{lang: _pl} // pl |
| 118 | Portuguese Tag = Tag{lang: _pt} // pt |
| 119 | BrazilianPortuguese Tag = Tag{lang: _pt, region: _BR} // pt-BR |
| 120 | EuropeanPortuguese Tag = Tag{lang: _pt, region: _PT} // pt-PT |
| 121 | Romanian Tag = Tag{lang: _ro} // ro |
| 122 | Russian Tag = Tag{lang: _ru} // ru |
| 123 | Sinhala Tag = Tag{lang: _si} // si |
| 124 | Slovak Tag = Tag{lang: _sk} // sk |
| 125 | Slovenian Tag = Tag{lang: _sl} // sl |
| 126 | Albanian Tag = Tag{lang: _sq} // sq |
| 127 | Serbian Tag = Tag{lang: _sr} // sr |
| 128 | SerbianLatin Tag = Tag{lang: _sr, script: _Latn} // sr-Latn |
| 129 | Swedish Tag = Tag{lang: _sv} // sv |
| 130 | Swahili Tag = Tag{lang: _sw} // sw |
| 131 | Tamil Tag = Tag{lang: _ta} // ta |
| 132 | Telugu Tag = Tag{lang: _te} // te |
| 133 | Thai Tag = Tag{lang: _th} // th |
| 134 | Turkish Tag = Tag{lang: _tr} // tr |
| 135 | Ukrainian Tag = Tag{lang: _uk} // uk |
| 136 | Urdu Tag = Tag{lang: _ur} // ur |
| 137 | Uzbek Tag = Tag{lang: _uz} // uz |
| 138 | Vietnamese Tag = Tag{lang: _vi} // vi |
| 139 | Chinese Tag = Tag{lang: _zh} // zh |
| 140 | SimplifiedChinese Tag = Tag{lang: _zh, script: _Hans} // zh-Hans |
| 141 | TraditionalChinese Tag = Tag{lang: _zh, script: _Hant} // zh-Hant |
| 142 | Zulu Tag = Tag{lang: _zu} // zu |
| 143 | ) |