tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

locales.gni (5918B)


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