| 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 |
import "golang.org/x/text/internal/language/compact" |
| 8 |
|
| 9 |
// TODO: Various sets of commonly use tags and regions. |
| 10 |
|
| 11 |
// MustParse is like Parse, but panics if the given BCP 47 tag cannot be parsed. |
| 12 |
// It simplifies safe initialization of Tag values. |
| 13 |
func MustParse(s string) Tag { |
| 14 |
t, err := Parse(s) |
| 15 |
if err != nil { |
| 16 |
panic(err) |
| 17 |
} |
| 18 |
return t |
| 19 |
} |
| 20 |
|
| 21 |
// MustParse is like Parse, but panics if the given BCP 47 tag cannot be parsed. |
| 22 |
// It simplifies safe initialization of Tag values. |
| 23 |
func (c CanonType) MustParse(s string) Tag { |
| 24 |
t, err := c.Parse(s) |
| 25 |
if err != nil { |
| 26 |
panic(err) |
| 27 |
} |
| 28 |
return t |
| 29 |
} |
| 30 |
|
| 31 |
// MustParseBase is like ParseBase, but panics if the given base cannot be parsed. |
| 32 |
// It simplifies safe initialization of Base values. |
| 33 |
func MustParseBase(s string) Base { |
| 34 |
b, err := ParseBase(s) |
| 35 |
if err != nil { |
| 36 |
panic(err) |
| 37 |
} |
| 38 |
return b |
| 39 |
} |
| 40 |
|
| 41 |
// MustParseScript is like ParseScript, but panics if the given script cannot be |
| 42 |
// parsed. It simplifies safe initialization of Script values. |
| 43 |
func MustParseScript(s string) Script { |
| 44 |
scr, err := ParseScript(s) |
| 45 |
if err != nil { |
| 46 |
panic(err) |
| 47 |
} |
| 48 |
return scr |
| 49 |
} |
| 50 |
|
| 51 |
// MustParseRegion is like ParseRegion, but panics if the given region cannot be |
| 52 |
// parsed. It simplifies safe initialization of Region values. |
| 53 |
func MustParseRegion(s string) Region { |
| 54 |
r, err := ParseRegion(s) |
| 55 |
if err != nil { |
| 56 |
panic(err) |
| 57 |
} |
| 58 |
return r |
| 59 |
} |
| 60 |
|
| 61 |
var ( |
| 62 |
und = Tag{} |
| 63 |
|
| 64 |
Und Tag = Tag{} |
| 65 |
|
| 66 |
Afrikaans Tag = Tag(compact.Afrikaans) |
| 67 |
Amharic Tag = Tag(compact.Amharic) |
| 68 |
Arabic Tag = Tag(compact.Arabic) |
| 69 |
ModernStandardArabic Tag = Tag(compact.ModernStandardArabic) |
| 70 |
Azerbaijani Tag = Tag(compact.Azerbaijani) |
| 71 |
Bulgarian Tag = Tag(compact.Bulgarian) |
| 72 |
Bengali Tag = Tag(compact.Bengali) |
| 73 |
Catalan Tag = Tag(compact.Catalan) |
| 74 |
Czech Tag = Tag(compact.Czech) |
| 75 |
Danish Tag = Tag(compact.Danish) |
| 76 |
German Tag = Tag(compact.German) |
| 77 |
Greek Tag = Tag(compact.Greek) |
| 78 |
English Tag = Tag(compact.English) |
| 79 |
AmericanEnglish Tag = Tag(compact.AmericanEnglish) |
| 80 |
BritishEnglish Tag = Tag(compact.BritishEnglish) |
| 81 |
Spanish Tag = Tag(compact.Spanish) |
| 82 |
EuropeanSpanish Tag = Tag(compact.EuropeanSpanish) |
| 83 |
LatinAmericanSpanish Tag = Tag(compact.LatinAmericanSpanish) |
| 84 |
Estonian Tag = Tag(compact.Estonian) |
| 85 |
Persian Tag = Tag(compact.Persian) |
| 86 |
Finnish Tag = Tag(compact.Finnish) |
| 87 |
Filipino Tag = Tag(compact.Filipino) |
| 88 |
French Tag = Tag(compact.French) |
| 89 |
CanadianFrench Tag = Tag(compact.CanadianFrench) |
| 90 |
Gujarati Tag = Tag(compact.Gujarati) |
| 91 |
Hebrew Tag = Tag(compact.Hebrew) |
| 92 |
Hindi Tag = Tag(compact.Hindi) |
| 93 |
Croatian Tag = Tag(compact.Croatian) |
| 94 |
Hungarian Tag = Tag(compact.Hungarian) |
| 95 |
Armenian Tag = Tag(compact.Armenian) |
| 96 |
Indonesian Tag = Tag(compact.Indonesian) |
| 97 |
Icelandic Tag = Tag(compact.Icelandic) |
| 98 |
Italian Tag = Tag(compact.Italian) |
| 99 |
Japanese Tag = Tag(compact.Japanese) |
| 100 |
Georgian Tag = Tag(compact.Georgian) |
| 101 |
Kazakh Tag = Tag(compact.Kazakh) |
| 102 |
Khmer Tag = Tag(compact.Khmer) |
| 103 |
Kannada Tag = Tag(compact.Kannada) |
| 104 |
Korean Tag = Tag(compact.Korean) |
| 105 |
Kirghiz Tag = Tag(compact.Kirghiz) |
| 106 |
Lao Tag = Tag(compact.Lao) |
| 107 |
Lithuanian Tag = Tag(compact.Lithuanian) |
| 108 |
Latvian Tag = Tag(compact.Latvian) |
| 109 |
Macedonian Tag = Tag(compact.Macedonian) |
| 110 |
Malayalam Tag = Tag(compact.Malayalam) |
| 111 |
Mongolian Tag = Tag(compact.Mongolian) |
| 112 |
Marathi Tag = Tag(compact.Marathi) |
| 113 |
Malay Tag = Tag(compact.Malay) |
| 114 |
Burmese Tag = Tag(compact.Burmese) |
| 115 |
Nepali Tag = Tag(compact.Nepali) |
| 116 |
Dutch Tag = Tag(compact.Dutch) |
| 117 |
Norwegian Tag = Tag(compact.Norwegian) |
| 118 |
Punjabi Tag = Tag(compact.Punjabi) |
| 119 |
Polish Tag = Tag(compact.Polish) |
| 120 |
Portuguese Tag = Tag(compact.Portuguese) |
| 121 |
BrazilianPortuguese Tag = Tag(compact.BrazilianPortuguese) |
| 122 |
EuropeanPortuguese Tag = Tag(compact.EuropeanPortuguese) |
| 123 |
Romanian Tag = Tag(compact.Romanian) |
| 124 |
Russian Tag = Tag(compact.Russian) |
| 125 |
Sinhala Tag = Tag(compact.Sinhala) |
| 126 |
Slovak Tag = Tag(compact.Slovak) |
| 127 |
Slovenian Tag = Tag(compact.Slovenian) |
| 128 |
Albanian Tag = Tag(compact.Albanian) |
| 129 |
Serbian Tag = Tag(compact.Serbian) |
| 130 |
SerbianLatin Tag = Tag(compact.SerbianLatin) |
| 131 |
Swedish Tag = Tag(compact.Swedish) |
| 132 |
Swahili Tag = Tag(compact.Swahili) |
| 133 |
Tamil Tag = Tag(compact.Tamil) |
| 134 |
Telugu Tag = Tag(compact.Telugu) |
| 135 |
Thai Tag = Tag(compact.Thai) |
| 136 |
Turkish Tag = Tag(compact.Turkish) |
| 137 |
Ukrainian Tag = Tag(compact.Ukrainian) |
| 138 |
Urdu Tag = Tag(compact.Urdu) |
| 139 |
Uzbek Tag = Tag(compact.Uzbek) |
| 140 |
Vietnamese Tag = Tag(compact.Vietnamese) |
| 141 |
Chinese Tag = Tag(compact.Chinese) |
| 142 |
SimplifiedChinese Tag = Tag(compact.SimplifiedChinese) |
| 143 |
TraditionalChinese Tag = Tag(compact.TraditionalChinese) |
| 144 |
Zulu Tag = Tag(compact.Zulu) |
| 145 |
) |