tags.go 5.4 KB

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