locales.gni 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. # Copyright 2014 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. import("//build/config/chromeos/ui_mode.gni")
  5. # This file creates |platform_pak_locales| which is the set of packed locales
  6. # based on the current platform. Locales in this list are formatted based on
  7. # what .pak files expect. The |platform_pak_locales| variable *may* contain
  8. # pseudolocales, depending on the |enable_pseudolocales| flag.
  9. # If you specifically want to have the locales variable with or without
  10. # pseudolocales, then use |locales_with_pseudolocales| or
  11. # |locales_without_pseudolocales|.
  12. # The following additional platform specific lists are created:
  13. # - |extended_locales| list of locales not shipped on desktop builds
  14. # - |android_bundle_locales_as_resources| locales formatted for XML output names
  15. # - |locales_as_apple_outputs| formatted for mac output bundles
  16. pseudolocales = [
  17. "ar-XB",
  18. "en-XA",
  19. ]
  20. # Superset of all locales used in Chrome with platform specific changes noted.
  21. all_chrome_locales =
  22. [
  23. "af",
  24. "am",
  25. "ar",
  26. "as",
  27. "az",
  28. "be",
  29. "bg",
  30. "bn",
  31. "bs",
  32. "ca",
  33. "cs",
  34. "cy",
  35. "da",
  36. "de",
  37. "el",
  38. "en-GB",
  39. "en-US",
  40. "es",
  41. "es-419", # "es-MX" in iOS (Mexico vs Latin America) "es-US" on Android
  42. "et",
  43. "eu",
  44. "fa",
  45. "fi",
  46. "fil", # "tl" in .xml but "fil" in TC and .pak
  47. "fr",
  48. "fr-CA",
  49. "gl",
  50. "gu",
  51. "he", # "iw" in .xml and TC but "he" in .pak
  52. "hi",
  53. "hr",
  54. "hu",
  55. "hy",
  56. "id", # "in" in .xml but "id" in TC and .pak
  57. "is",
  58. "it",
  59. "ja",
  60. "ka",
  61. "kk",
  62. "km",
  63. "kn",
  64. "ko",
  65. "ky",
  66. "lo",
  67. "lt",
  68. "lv",
  69. "mk",
  70. "ml",
  71. "mn",
  72. "mr",
  73. "ms",
  74. "my",
  75. "nb", # "no" in TC but "nb" in .xml and .pak
  76. "ne",
  77. "nl",
  78. "or",
  79. "pa",
  80. "pl",
  81. "pt-BR", # just "pt" in iOS
  82. "pt-PT",
  83. "ro",
  84. "ru",
  85. "si",
  86. "sk",
  87. "sl",
  88. "sq",
  89. "sr",
  90. "sr-Latn", # -b+sr+Latn in .xml
  91. "sv",
  92. "sw",
  93. "ta",
  94. "te",
  95. "th",
  96. "tr",
  97. "uk",
  98. "ur",
  99. "uz",
  100. "vi",
  101. "zh-CN",
  102. "zh-HK",
  103. "zh-TW",
  104. "zu",
  105. ] + pseudolocales
  106. if (is_ios) {
  107. # Chrome on iOS uses "es-MX" and "pt" for "es-419" and "pt-BR".
  108. all_chrome_locales -= [
  109. "es-419",
  110. "pt-BR",
  111. ]
  112. all_chrome_locales += [
  113. "es-MX",
  114. "pt",
  115. ]
  116. }
  117. # Chrome locales not on Windows, Mac, or Linux.
  118. # This list is used for all platforms except Android. On Android, this list is
  119. # modified to exclude locales that are not used on Android, so
  120. # `platform_pak_locales - extended_locales` works as expected.
  121. extended_locales = [
  122. "as",
  123. "az",
  124. "be",
  125. "bs",
  126. "cy",
  127. "eu",
  128. "fr-CA",
  129. "gl",
  130. "hy",
  131. "is",
  132. "ka",
  133. "kk",
  134. "km",
  135. "ky",
  136. "lo",
  137. "mk",
  138. "mn",
  139. "my",
  140. "ne",
  141. "or",
  142. "pa",
  143. "si",
  144. "sq",
  145. "sr-Latn",
  146. "uz",
  147. "zh-HK",
  148. "zu",
  149. ]
  150. # Chrome locales not on Android.
  151. # These locales have not yet been tested yet. Specifically, AOSP has not been
  152. # translated to Welsh at the time of writing (April 2022):
  153. # https://cs.android.com/android/platform/superproject/+/master:build/make/target/product/languages_default.mk
  154. # Due to this, the only way a user could see Welsh strings - assuming they were
  155. # built - would be to manually switch their "Chrome language" in Chrome's
  156. # language settings to Welsh, so Welsh usage would probably be very low.
  157. _non_android_locales = [ "cy" ]
  158. # Setup |platform_pak_locales| for each platform.
  159. platform_pak_locales = all_chrome_locales
  160. if (is_android) {
  161. platform_pak_locales -= _non_android_locales
  162. extended_locales -= _non_android_locales
  163. } else {
  164. platform_pak_locales -= extended_locales
  165. }
  166. # The base list for all platforms except Android excludes the extended locales.
  167. # Add or subtract platform specific locales below.
  168. if (is_chromeos) {
  169. platform_pak_locales += [
  170. "cy",
  171. "eu",
  172. "gl",
  173. "is",
  174. "zu",
  175. ]
  176. platform_pak_locales -= [ "ur" ]
  177. } else if (is_ios) {
  178. platform_pak_locales -= [
  179. "af",
  180. "am",
  181. "bn",
  182. "et",
  183. "fil",
  184. "gu",
  185. "kn",
  186. "lv",
  187. "ml",
  188. "mr",
  189. "sl",
  190. "sw",
  191. "ta",
  192. "te",
  193. "ur",
  194. ]
  195. }
  196. # List for Android locale names in .xml exports. Note: needs to stay in sync
  197. # with |ToAndroidLocaleName| in build/android/gyp/util/resource_utils.py.
  198. if (is_android) {
  199. # - add r: (e.g. zh-HK -> zh-rHK )
  200. android_bundle_locales_as_resources = []
  201. foreach(_locale, platform_pak_locales) {
  202. android_bundle_locales_as_resources +=
  203. [ string_replace(_locale, "-", "-r") ]
  204. }
  205. # - remove en-US
  206. # - swap: (he, id, en-419, fil) -> (iw, in, es-rUS, tl)
  207. # - sr-rLatn -> -b+sr+Latn
  208. android_bundle_locales_as_resources -= [
  209. "en-rUS",
  210. "es-r419",
  211. "fil",
  212. "he",
  213. "id",
  214. "sr-rLatn",
  215. ]
  216. android_bundle_locales_as_resources += [
  217. "b+sr+Latn",
  218. "es-rUS",
  219. "in",
  220. "iw",
  221. "tl",
  222. ]
  223. }
  224. locales_without_pseudolocales = platform_pak_locales - pseudolocales
  225. locales_with_pseudolocales = platform_pak_locales
  226. declare_args() {
  227. # We want to give pseudolocales to everyone except end-users (devs & QA).
  228. # Note that this only packages the locales in, and doesn't add the ui to enable them.
  229. enable_pseudolocales = !is_official_build
  230. }
  231. if (!enable_pseudolocales) {
  232. platform_pak_locales -= pseudolocales
  233. }
  234. if (is_apple) {
  235. # Same as the locales list but in the format Mac expects for output files:
  236. # it uses underscores instead of hyphens, and "en" instead of "en-US".
  237. locales_as_apple_outputs = []
  238. foreach(locale, platform_pak_locales) {
  239. if (locale == "en-US") {
  240. locales_as_apple_outputs += [ "en" ]
  241. } else {
  242. locales_as_apple_outputs += [ string_replace(locale, "-", "_") ]
  243. }
  244. }
  245. }