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

Side by Side Diff: icu52/scripts/trim_data.sh

Issue 239543018: Trim ICU data to reduce the download size/memory usage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/
Patch Set: Created 6 years, 8 months 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 | Annotate | Revision Log
« no previous file with comments | « icu52/scripts/currencies_to_drop.list ('k') | icu52/source/data/curr/af.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
Added: svn:executable
+ *
OLDNEW
(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
OLDNEW
« no previous file with comments | « icu52/scripts/currencies_to_drop.list ('k') | icu52/source/data/curr/af.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698