OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 |
| 7 # Remove display names for languages that are not listed in the accept-language |
| 8 # list of Chromium. |
| 9 function filter_display_language_names { |
| 10 UI_LANG_PATTERN="(${UI_LANGUAGES})[^a-z]" |
| 11 |
| 12 echo "Filtering out display names for non-UI languages in ${langdatapath}" |
| 13 for lang in $(grep -v '^#' chrome_ui_languages.list) |
| 14 do |
| 15 target=${langdatapath}/${lang}.txt |
| 16 sed -r -i \ |
| 17 '/^ Keys\{$/,/^ \}$/d |
| 18 /^ Languages\{$/, /^ \}$/ { |
| 19 /^ Languages\{$/p |
| 20 /^ '${UI_LANG_PATTERN}'/p |
| 21 /^ \}$/p |
| 22 d |
| 23 } |
| 24 /^ Types\{$/,/^ \}$/d |
| 25 /^ Variants\{$/,/^ \}$/d' ${target} |
| 26 done |
| 27 } |
| 28 |
| 29 |
| 30 # Keep only the minimum locale data for non-UI languages. |
| 31 function abridge_locale_data_for_non_ui_languages { |
| 32 EXTRA_LANGUAGES=$(egrep -v -e '^#' -e "(${UI_LANGUAGES})" accept_lang.list) |
| 33 |
| 34 echo Creating minimum locale data in ${localedatapath} |
| 35 for lang in ${EXTRA_LANGUAGES} |
| 36 do |
| 37 target=${localedatapath}/${lang}.txt |
| 38 [ -e ${target} ] || { echo "missing ${lang}"; continue; } |
| 39 echo Overwriting ${target} ... |
| 40 sed -n -r -i \ |
| 41 '1, /^'${lang}'\{$/p |
| 42 /^ AuxExemplarCharacters\{.*\}$/p |
| 43 /^ AuxExemplarCharacters\{$/, /^ \}$/p |
| 44 /^ ExemplarCharacters\{.*\}$/p |
| 45 /^ ExemplarCharacters\{$/, /^ \}$/p |
| 46 /^ (LocaleScript|layout)\{$/, /^ \}$/p |
| 47 /^ Version\{.*$/p |
| 48 /^\}$/p' ${target} |
| 49 done |
| 50 |
| 51 echo Creating minimum locale data in ${langdatapath} |
| 52 for lang in ${EXTRA_LANGUAGES} |
| 53 do |
| 54 target=${langdatapath}/${lang}.txt |
| 55 [ -e ${target} ] || { echo "missing ${lang}"; continue; } |
| 56 echo Overwriting ${target} ... |
| 57 sed -n -r -i \ |
| 58 '1, /^'${lang}'\{$/p |
| 59 /^ Languages\{$/, /^ \}$/ { |
| 60 /^ Languages\{$/p |
| 61 /^ '${lang}'\{.*\}$/p |
| 62 /^ \}$/p |
| 63 } |
| 64 /^\}$/p' ${target} |
| 65 done |
| 66 } |
| 67 |
| 68 # Drop historic currencies. |
| 69 # TODO(jshin): Use ucurr_isAvailable in ICU to drop more currencies. |
| 70 # See also http://en.wikipedia.org/wiki/List_of_circulating_currencies |
| 71 function filter_currency_data { |
| 72 for currency in $(grep -v '^#' currencies_to_drop.list) |
| 73 do |
| 74 OP=${DROPLIST:+|} |
| 75 DROPLIST=${DROPLIST}${OP}${currency} |
| 76 done |
| 77 DROPLIST="(${DROPLIST})\{" |
| 78 |
| 79 cd "${dataroot}/curr" |
| 80 for i in *.txt |
| 81 do |
| 82 [ $i != 'supplementalData.txt' ] && \ |
| 83 sed -r -i '/^ '$DROPLIST'/, /^ }/ d' $i |
| 84 done |
| 85 } |
| 86 |
| 87 # Remove the display names for numeric region codes other than |
| 88 # 419 (Latin America) because we don't use them. |
| 89 function filter_region_data { |
| 90 cd "${dataroot}/region" |
| 91 sed -i '/[0-35-9][0-9][0-9]{/ d' *.txt |
| 92 } |
| 93 |
| 94 |
| 95 |
| 96 function remove_exemplar_cities { |
| 97 cd "${dataroot}/zone" |
| 98 for i in *.txt |
| 99 do |
| 100 [ $i != 'root.txt' ] && \ |
| 101 sed -i '/^ zoneStrings/, /^ "meta:/ { |
| 102 /^ zoneStrings/ p |
| 103 /^ "meta:/ p |
| 104 d |
| 105 }' $i |
| 106 done |
| 107 } |
| 108 |
| 109 dataroot="$(dirname $0)/../source/data" |
| 110 localedatapath="${dataroot}/locales" |
| 111 langdatapath="${dataroot}/lang" |
| 112 |
| 113 for lang in $(grep -v '^#' chrome_ui_languages.list) |
| 114 do |
| 115 # Set $OP to '|' only if $UI_LANGUAGES is not empty. |
| 116 OP=${UI_LANGUAGES:+|} |
| 117 UI_LANGUAGES="${UI_LANGUAGES}${OP}${lang}" |
| 118 done |
| 119 |
| 120 |
| 121 filter_display_language_names |
| 122 abridge_locale_data_for_non_ui_languages |
| 123 filter_currency_data |
| 124 filter_region_data |
| 125 |
| 126 # Chromium OS needs exemplar cities for timezones, but not Chromium. |
| 127 # It'll save 400kB (uncompressed), but the size difference in |
| 128 # 7z compressed installer is <= 100kB. |
| 129 # TODO(jshin): Make separate data files for CrOS and Chromium. |
| 130 #fremove_exemplar_cities |
OLD | NEW |