Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: scripts/trim_data.sh

Issue 2442923002: ICU update to 58 part 2 (Closed)
Patch Set: apply more patches and updates; almost ready to roll Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « patches/xlit_badcast.patch ('k') | source/common/dictbe.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. 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 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 6
7 # Remove entries currently not used in Chromium/V8.
8 function filter_locale_data {
9 echo Removing unncessary categories in ${localedatapath}
10 for langpath in ${localedatapath}/*.txt
11 do
12 echo Overwriting ${langpath} ...
13 sed -r -i \
14 '/^ characterLabel\{$/,/^ \}$/d
15 /^ AuxExemplarCharacters\{.*\}$/d
16 /^ AuxExemplarCharacters\{$/, /^ \}$/d
17 /^ ExemplarCharacters\{.*\}$/d
18 /^ ExemplarCharacters\{$/, /^ \}$/d
19 /^ (mon|tue|wed|thu|fri|sat|sun|quarter)(|-short|-narrow)\{$/, /^ \}$/d' ${langpath}
20 done
21 }
22
7 # Remove display names for languages that are not listed in the accept-language 23 # Remove display names for languages that are not listed in the accept-language
8 # list of Chromium. 24 # list of Chromium.
9 function filter_display_language_names { 25 function filter_display_language_names {
10 for lang in $(grep -v '^#' "${scriptdir}/accept_lang.list") 26 for lang in $(grep -v '^#' "${scriptdir}/accept_lang.list")
11 do 27 do
12 # Set $OP to '|' only if $ACCEPT_LANG_PATTERN is not empty. 28 # Set $OP to '|' only if $ACCEPT_LANG_PATTERN is not empty.
13 OP=${ACCEPT_LANG_PATTERN:+|} 29 OP=${ACCEPT_LANG_PATTERN:+|}
14 ACCEPT_LANG_PATTERN="${ACCEPT_LANG_PATTERN}${OP}${lang}" 30 ACCEPT_LANG_PATTERN="${ACCEPT_LANG_PATTERN}${OP}${lang}"
15 done 31 done
16 ACCEPT_LANG_PATTERN="(${ACCEPT_LANG_PATTERN})[^a-z]" 32 ACCEPT_LANG_PATTERN="(${ACCEPT_LANG_PATTERN})[^a-z]"
17 33
18 echo "Filtering out display names for non-A-L languages ${langdatapath}" 34 echo "Filtering out display names for non-A-L languages in ${langdatapath}"
19 for lang in $(grep -v '^#' "${scriptdir}/chrome_ui_languages.list") 35 for langpath in ${langdatapath}/*.txt
20 do 36 do
21 target=${langdatapath}/${lang}.txt 37 target=${langpath}
22 echo Overwriting ${target} ... 38 echo Overwriting ${target} ...
23 sed -r -i \ 39 sed -r -i \
24 '/^ Keys\{$/,/^ \}$/d 40 '/^ Keys\{$/,/^ \}$/d
25 /^ Languages\{$/, /^ \}$/ { 41 /^ Languages\{$/, /^ \}$/ {
26 /^ Languages\{$/p 42 /^ Languages\{$/p
27 /^ '${ACCEPT_LANG_PATTERN}'/p 43 /^ '${ACCEPT_LANG_PATTERN}'/p
28 /^ \}$/p 44 /^ \}$/p
29 d 45 d
30 } 46 }
31 /^ Types\{$/,/^ \}$/d 47 /^ Types\{$/,/^ \}$/d
48 /^ Types%short\{$/,/^ \}$/d
49 /^ characterLabelPattern\{$/,/^ \}$/d
32 /^ Variants\{$/,/^ \}$/d' ${target} 50 /^ Variants\{$/,/^ \}$/d' ${target}
33 51
34 # Delete an empty "Languages" block. Otherwise, getting the display 52 # Delete an empty "Languages" block. Otherwise, getting the display
35 # name for all the language in a given locale (e.g. en_GB) would fail 53 # name for all the language in a given locale (e.g. en_GB) would fail
36 # when the above filtering sed command results in an empty "Languages" 54 # when the above filtering sed command results in an empty "Languages"
37 # block. 55 # block.
38 sed -r -i \ 56 sed -r -i \
39 '/^ Languages\{$/ { 57 '/^ Languages\{$/ {
40 N 58 N
41 /^ Languages\{\n \}/ d 59 /^ Languages\{\n \}/ d
42 }' ${target} 60 }' ${target}
43 done 61 done
44 } 62 }
45 63
46 64
47 # Keep only the minimum locale data for non-UI languages. 65 # Keep only the minimum locale data for non-UI languages.
48 function abridge_locale_data_for_non_ui_languages { 66 function abridge_locale_data_for_non_ui_languages {
49 for lang in $(grep -v '^#' "${scriptdir}/chrome_ui_languages.list") 67 for lang in $(grep -v '^#' "${scriptdir}/chrome_ui_languages.list")
50 do 68 do
51 # Set $OP to '|' only if $UI_LANGUAGES is not empty. 69 # Set $OP to '|' only if $UI_LANGUAGES is not empty.
52 OP=${UI_LANGUAGES:+|} 70 OP=${UI_LANGUAGES:+|}
53 UI_LANGUAGES="${UI_LANGUAGES}${OP}${lang}" 71 UI_LANGUAGES="${UI_LANGUAGES}${OP}${lang}"
54 done 72 done
55 73
56 EXTRA_LANGUAGES=$(egrep -v -e '^#' -e "(${UI_LANGUAGES})" \ 74 EXTRA_LANGUAGES=$(egrep -v -e '^#' -e "(${UI_LANGUAGES})" \
57 "${scriptdir}/accept_lang.list") 75 "${scriptdir}/accept_lang.list")
58 76
59 echo Creating minimum locale data in ${localedatapath} 77 echo Creating minimum locale data in ${localedatapath}
60 for lang in ${EXTRA_LANGUAGES} 78 for lang in ${EXTRA_LANGUAGES}
61 do 79 do
62 target=${localedatapath}/${lang}.txt 80 target=${localedatapath}/${lang}.txt
63 [ -e ${target} ] || { echo "missing ${lang}"; continue; } 81 [ -e ${target} ] || { echo "missing ${lang}"; continue; }
64 echo Overwriting ${target} ... 82 echo Overwriting ${target} ...
65 83
66 # Do not include '%%Parent' line on purpose. 84 # Do not include '%%Parent' line on purpose.
67 sed -n -r -i \ 85 sed -n -r -i \
68 '1, /^'${lang}'\{$/p 86 '1, /^'${lang}'\{$/p
69 /^ "%%ALIAS"\{/p 87 /^ "%%ALIAS"\{/p
70 /^ AuxExemplarCharacters\{.*\}$/p
71 /^ AuxExemplarCharacters\{$/, /^ \}$/p
72 /^ ExemplarCharacters\{.*\}$/p
73 /^ ExemplarCharacters\{$/, /^ \}$/p
74 /^ (LocaleScript|layout)\{$/, /^ \}$/p 88 /^ (LocaleScript|layout)\{$/, /^ \}$/p
75 /^ Version\{.*$/p 89 /^ Version\{.*$/p
76 /^\}$/p' ${target} 90 /^\}$/p' ${target}
77 done 91 done
78 92
79 echo Creating minimum locale data in ${langdatapath} 93 echo Creating minimum locale data in ${langdatapath}
80 for lang in ${EXTRA_LANGUAGES} 94 for lang in ${EXTRA_LANGUAGES}
81 do 95 do
82 target=${langdatapath}/${lang}.txt 96 target=${langdatapath}/${lang}.txt
83 [ -e ${target} ] || { echo "missing ${lang}"; continue; } 97 [ -e ${target} ] || { echo "missing ${lang}"; continue; }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 196 }
183 197
184 treeroot="$(dirname "$0")/.." 198 treeroot="$(dirname "$0")/.."
185 dataroot="${treeroot}/source/data" 199 dataroot="${treeroot}/source/data"
186 scriptdir="${treeroot}/scripts" 200 scriptdir="${treeroot}/scripts"
187 localedatapath="${dataroot}/locales" 201 localedatapath="${dataroot}/locales"
188 langdatapath="${dataroot}/lang" 202 langdatapath="${dataroot}/lang"
189 203
190 204
191 205
206 filter_locale_data
192 filter_display_language_names 207 filter_display_language_names
193 abridge_locale_data_for_non_ui_languages 208 abridge_locale_data_for_non_ui_languages
194 filter_currency_data 209 filter_currency_data
195 filter_region_data 210 filter_region_data
196 remove_legacy_chinese_codepoint_collation 211 remove_legacy_chinese_codepoint_collation
197 filter_unit_data 212 filter_unit_data
198 213
199 # Chromium OS needs exemplar cities for timezones, but not Chromium. 214 # Chromium OS needs exemplar cities for timezones, but not Chromium.
200 # It'll save 400kB (uncompressed), but the size difference in 215 # It'll save 400kB (uncompressed), but the size difference in
201 # 7z compressed installer is <= 100kB. 216 # 7z compressed installer is <= 100kB.
202 # TODO(jshin): Make separate data files for CrOS and Chromium. 217 # TODO(jshin): Make separate data files for CrOS and Chromium.
203 #remove_exemplar_cities 218 #remove_exemplar_cities
OLDNEW
« no previous file with comments | « patches/xlit_badcast.patch ('k') | source/common/dictbe.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698