Skip to content

Commit

Permalink
Adjust calendar locale data trimming on Andorid
Browse files Browse the repository at this point in the history
On Android, add Islamic calendar to Arabic and Farsi locales
and Indian calendar to Hindi locale. Also add both variants
of Ethiopic calendars to am/root.

There was a 'typo' in the locale trimming script for Android
('arabic' instead of 'islamic' was specified.). As a result,
Date formatting in ar-SA (where the default calendar is
Islamic) failed for the lack of locale data.

Add back calendar entries to data/locales/root.txt. They're
necessary to support locale-specific calendars on Android
(e.g. islamic on ar/fa, japanese on ja, hebrew on he, etc).

Adjust the drop list for the data file for cast. More
locale variants have been added since it's made. Drop
locale bundles for newly added variants.

Drop zone/unit data for 8 locales Android Chrome does not
yet support. This saves over 100 kB.

For all platforms, drop a few more items not yet used in
Chromium/v8.

With this change, the net data size decreased on all platforms,
paving the way to add more locale variants in a subsequent CL.

    Previous   This CL  Platform
     6375056   6235856  android
     4916608   4714896  cast
    10268240  10258960  common
      880512    879104  flutter
     6361376   6195600  ios

TBR=ftang@chromium.org,gsathya@chromium.org
Bug: v8:8432
Test: v8: intl/regress-8432-*
Change-Id: Iafd94c08ea4e88b33aed4724309636c3e224bdc2
Reviewed-on: https://chromium-review.googlesource.com/c/1325943
Reviewed-by: Jungshik Shin <jshin@chromium.org>
  • Loading branch information
jungshik committed Nov 14, 2018
1 parent 45f655f commit ecae5c0
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 64 deletions.
Binary file modified android/icudtl.dat
Binary file not shown.
163 changes: 103 additions & 60 deletions cast/cast-removed-resources.txt

Large diffs are not rendered by default.

Binary file modified cast/icudtl.dat
Binary file not shown.
50 changes: 47 additions & 3 deletions cast/patch_locale.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,32 @@ do
/^\}$/p' ${target}
done

echo Creating minimum locale data in ${langdatapath}
for lang in ${EXTRA_LANGUAGES}
do
target=lang/${lang}.txt
[ -e ${target} ] || { echo "missing ${lang}"; continue; }
echo Overwriting ${target} ...

# Do not include '%%Parent' line on purpose.
sed -n -r -i \
'1, /^'${lang}'\{$/p
/^ "%%ALIAS"\{/p
/^ Languages\{$/, /^ \}$/ {
/^ Languages\{$/p
/^ '${lang}'\{.*\}$/p
/^ \}$/p
}
/^\}$/p' ${target}
done

echo Overwriting curr/reslocal.mk to drop the currency names
echo for ${EXTRA_LANGUAGES}
for lang in ${EXTRA_LANGUAGES}
do
sed -i -e '/'$lang'.txt/ d' curr/reslocal.mk
sed -i -e '/'$lang'.txt/ d' zone/reslocal.mk
sed -i -e '/'$lang'.txt/ d' unit/reslocal.mk
done

# Remove exemplar cities in timezone data.
Expand Down Expand Up @@ -117,20 +138,31 @@ for i in locales/*.txt; do
EXTRA_CAL='dangi'
;;
am)
EXTRA_CAL='ethiopic'
EXTRA_CAL='ethiopic|ethiopic-amete-alem'
;;
he)
EXTRA_CAL='hebrew'
;;
ar)
EXTRA_CAL='arabic'
# Other Islamic calendar formats are not in locales other than root.
# ar-SA's default is islamic-umalqura, but its format entries are
# specified in root via aliases.
EXTRA_CAL='islamic'
;;
fa)
EXTRA_CAL='persian'
EXTRA_CAL='persian|islamic'
;;
ja)
EXTRA_CAL='japanese'
;;
# When adding other Indian locales for Android,
# add 'indian' calendar to them as well.
hi)
EXTRA_CAL='indian'
;;
root)
EXTRA_CAL='buddhist|chinese|roc|dangi|ethiopic|ethiopic-amete-alem|japanese|hebrew|islamic|islamic-(umalqura|civil|tbla|rgsa)|persian|indian'
;;
*)
EXTRA_CAL=''
;;
Expand All @@ -152,4 +184,16 @@ for i in locales/*.txt; do
}' -i $i
done

# Delete Japanese era display names in root. 'ja' has Japanese era names
# so that root does not need them.
# The same is true of eras and monthNames for Islamic calendar.
sed -r -i \
'/^ japanese\{$/,/^ \}$/ {
/^ eras\{/,/^ \}$/d
}
/^ islamic\{$/,/^ \}$/ {
/^ eras\{/,/^ \}$/d
/^ monthNames\{/,/^ \}$/d
}' locales/root.txt

echo DONE.
Binary file modified common/icudtb.dat
Binary file not shown.
Binary file modified common/icudtl.dat
Binary file not shown.
Binary file modified flutter/icudtl.dat
Binary file not shown.
Binary file modified ios/icudtl.dat
Binary file not shown.
7 changes: 6 additions & 1 deletion scripts/trim_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ function filter_locale_data {
/^ AuxExemplarCharacters\{$/, /^ \}$/d
/^ ExemplarCharacters\{.*\}$/d
/^ ExemplarCharacters\{$/, /^ \}$/d
/^ (mon|tue|wed|thu|fri|sat|sun)(|-short|-narrow)\{$/, /^ \}$/d' ${langpath}
/^ ExemplarCharactersNumbers\{.*\}$/d
/^ ExemplarCharactersPunctuation\{.*\}$/d
/^ ExemplarCharactersPunctuation\{$/, /^ \}$/d
/^ (mon|tue|wed|thu|fri|sat|sun)(|-short|-narrow)\{$/, /^ \}$/d
/^ (mon|tue|wed|thu|fri|sat|sun)(|-short|-narrow)\{.*\}$/d
/^ (mon|tue|wed|thu|fri|sat|sun)-(short|narrow):alias\{.*\}$/d' ${langpath}
# Delete empty blocks. Otherwise, locale fallback fails.
# See crbug.com/v8/8414 .
sed -r -i \
Expand Down

0 comments on commit ecae5c0

Please sign in to comment.