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

Side by Side Diff: scripts/trim_data.sh

Issue 264973016: Add back display names for non-UI languages in A-L list (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/icu52/
Patch Set: Created 6 years, 7 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 | « scripts/chrome_ui_languages.list ('k') | source/data/in/icudtl.dat » ('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 display names for languages that are not listed in the accept-language 7 # Remove display names for languages that are not listed in the accept-language
8 # list of Chromium. 8 # list of Chromium.
9 function filter_display_language_names { 9 function filter_display_language_names {
10 UI_LANG_PATTERN="(${UI_LANGUAGES})[^a-z]" 10 for lang in $(grep -v '^#' accept_lang.list)
11 do
12 # Set $OP to '|' only if $ACCEPT_LANG_PATTERN is not empty.
13 OP=${ACCEPT_LANG_PATTERN:+|}
14 ACCEPT_LANG_PATTERN="${ACCEPT_LANG_PATTERN}${OP}${lang}"
15 done
16 ACCEPT_LANG_PATTERN="(${ACCEPT_LANG_PATTERN})[^a-z]"
11 17
12 echo "Filtering out display names for non-UI languages in ${langdatapath}" 18 echo "Filtering out display names for non-A-L languages ${langdatapath}"
13 for lang in $(grep -v '^#' chrome_ui_languages.list) 19 for lang in $(grep -v '^#' chrome_ui_languages.list)
14 do 20 do
15 target=${langdatapath}/${lang}.txt 21 target=${langdatapath}/${lang}.txt
22 echo Overwriting ${target} ...
16 sed -r -i \ 23 sed -r -i \
17 '/^ Keys\{$/,/^ \}$/d 24 '/^ Keys\{$/,/^ \}$/d
18 /^ Languages\{$/, /^ \}$/ { 25 /^ Languages\{$/, /^ \}$/ {
19 /^ Languages\{$/p 26 /^ Languages\{$/p
20 /^ '${UI_LANG_PATTERN}'/p 27 /^ '${ACCEPT_LANG_PATTERN}'/p
21 /^ \}$/p 28 /^ \}$/p
22 d 29 d
23 } 30 }
24 /^ Types\{$/,/^ \}$/d 31 /^ Types\{$/,/^ \}$/d
25 /^ Variants\{$/,/^ \}$/d' ${target} 32 /^ Variants\{$/,/^ \}$/d' ${target}
26 done 33 done
27 } 34 }
28 35
29 36
30 # Keep only the minimum locale data for non-UI languages. 37 # Keep only the minimum locale data for non-UI languages.
31 function abridge_locale_data_for_non_ui_languages { 38 function abridge_locale_data_for_non_ui_languages {
39 for lang in $(grep -v '^#' chrome_ui_languages.list)
40 do
41 # Set $OP to '|' only if $UI_LANGUAGES is not empty.
42 OP=${UI_LANGUAGES:+|}
43 UI_LANGUAGES="${UI_LANGUAGES}${OP}${lang}"
44 done
45
32 EXTRA_LANGUAGES=$(egrep -v -e '^#' -e "(${UI_LANGUAGES})" accept_lang.list) 46 EXTRA_LANGUAGES=$(egrep -v -e '^#' -e "(${UI_LANGUAGES})" accept_lang.list)
33 47
34 echo Creating minimum locale data in ${localedatapath} 48 echo Creating minimum locale data in ${localedatapath}
35 for lang in ${EXTRA_LANGUAGES} 49 for lang in ${EXTRA_LANGUAGES}
36 do 50 do
37 target=${localedatapath}/${lang}.txt 51 target=${localedatapath}/${lang}.txt
38 [ -e ${target} ] || { echo "missing ${lang}"; continue; } 52 [ -e ${target} ] || { echo "missing ${lang}"; continue; }
39 echo Overwriting ${target} ... 53 echo Overwriting ${target} ...
40 sed -n -r -i \ 54 sed -n -r -i \
41 '1, /^'${lang}'\{$/p 55 '1, /^'${lang}'\{$/p
56 /^ "%%ALIAS"\{/p
42 /^ AuxExemplarCharacters\{.*\}$/p 57 /^ AuxExemplarCharacters\{.*\}$/p
43 /^ AuxExemplarCharacters\{$/, /^ \}$/p 58 /^ AuxExemplarCharacters\{$/, /^ \}$/p
44 /^ ExemplarCharacters\{.*\}$/p 59 /^ ExemplarCharacters\{.*\}$/p
45 /^ ExemplarCharacters\{$/, /^ \}$/p 60 /^ ExemplarCharacters\{$/, /^ \}$/p
46 /^ (LocaleScript|layout)\{$/, /^ \}$/p 61 /^ (LocaleScript|layout)\{$/, /^ \}$/p
47 /^ Version\{.*$/p 62 /^ Version\{.*$/p
48 /^\}$/p' ${target} 63 /^\}$/p' ${target}
49 done 64 done
50 65
51 echo Creating minimum locale data in ${langdatapath} 66 echo Creating minimum locale data in ${langdatapath}
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 sed -i '/^ zoneStrings/, /^ "meta:/ { 116 sed -i '/^ zoneStrings/, /^ "meta:/ {
102 /^ zoneStrings/ p 117 /^ zoneStrings/ p
103 /^ "meta:/ p 118 /^ "meta:/ p
104 d 119 d
105 }' $i 120 }' $i
106 done 121 done
107 } 122 }
108 123
109 # Keep only duration and compound in units* sections. 124 # Keep only duration and compound in units* sections.
110 function filter_locale_data { 125 function filter_locale_data {
111 for i in "${dataroot}/locales/*.txt" 126 for i in ${dataroot}/locales/*.txt
112 do 127 do
113 echo Overwriting $i ... 128 echo Overwriting $i ...
114 sed -r -i \ 129 sed -r -i \
115 '/^ units(|Narrow|Short)\{$/, /^ \}$/ { 130 '/^ units(|Narrow|Short)\{$/, /^ \}$/ {
116 /^ units(|Narrow|Short)\{$/ p 131 /^ units(|Narrow|Short)\{$/ p
117 /^ (duration|compound)\{$/, /^ \}$/ p 132 /^ (duration|compound)\{$/, /^ \}$/ p
118 /^ \}$/ p 133 /^ \}$/ p
119 d 134 d
120 }' ${i} 135 }' ${i}
121 done 136 done
122 } 137 }
123 138
124 # big5han and gb2312han collation do not make any sense and nobody uses them. 139 # big5han and gb2312han collation do not make any sense and nobody uses them.
125 function remove_legacy_chinese_codepoint_collation { 140 function remove_legacy_chinese_codepoint_collation {
126 echo "Removing Big5 / GB2312 collation data from Chinese locale" 141 echo "Removing Big5 / GB2312 collation data from Chinese locale"
127 target="${dataroot}/coll/zh.txt" 142 target="${dataroot}/coll/zh.txt"
128 echo "Overwriting ${target}" 143 echo "Overwriting ${target}"
129 sed -r -i '/^ (big5|gb2312)han\{$/,/^ \}$/ d' ${target} 144 sed -r -i '/^ (big5|gb2312)han\{$/,/^ \}$/ d' ${target}
130 } 145 }
131 146
132 dataroot="$(dirname $0)/../source/data" 147 dataroot="$(dirname $0)/../source/data"
133 localedatapath="${dataroot}/locales" 148 localedatapath="${dataroot}/locales"
134 langdatapath="${dataroot}/lang" 149 langdatapath="${dataroot}/lang"
135 150
136 for lang in $(grep -v '^#' chrome_ui_languages.list)
137 do
138 # Set $OP to '|' only if $UI_LANGUAGES is not empty.
139 OP=${UI_LANGUAGES:+|}
140 UI_LANGUAGES="${UI_LANGUAGES}${OP}${lang}"
141 done
142 151
143 152
144 filter_display_language_names 153 filter_display_language_names
145 abridge_locale_data_for_non_ui_languages 154 abridge_locale_data_for_non_ui_languages
146 filter_currency_data 155 filter_currency_data
147 filter_region_data 156 filter_region_data
148 remove_legacy_chinese_codepoint_collation 157 remove_legacy_chinese_codepoint_collation
149 filter_locale_data 158 filter_locale_data
150 159
151 # Chromium OS needs exemplar cities for timezones, but not Chromium. 160 # Chromium OS needs exemplar cities for timezones, but not Chromium.
152 # It'll save 400kB (uncompressed), but the size difference in 161 # It'll save 400kB (uncompressed), but the size difference in
153 # 7z compressed installer is <= 100kB. 162 # 7z compressed installer is <= 100kB.
154 # TODO(jshin): Make separate data files for CrOS and Chromium. 163 # TODO(jshin): Make separate data files for CrOS and Chromium.
155 #remove_exemplar_cities 164 #remove_exemplar_cities
OLDNEW
« no previous file with comments | « scripts/chrome_ui_languages.list ('k') | source/data/in/icudtl.dat » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698