Adjust calendar locale data trimming on Andorid

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>
diff --git a/android/icudtl.dat b/android/icudtl.dat
index 2a7a902..e6402ef 100644
--- a/android/icudtl.dat
+++ b/android/icudtl.dat
Binary files differ
diff --git a/cast/cast-removed-resources.txt b/cast/cast-removed-resources.txt
index 18d7a6b..dd6d5c1 100644
--- a/cast/cast-removed-resources.txt
+++ b/cast/cast-removed-resources.txt
@@ -3,40 +3,41 @@
 currencyNumericCodes.res
 windowsZones.res
 
+coll/am.res
 coll/ar.res
 coll/bg.res
 coll/bn.res
 coll/ca.res
 coll/cs.res
-coll/de.res
-coll/de_.res
 coll/de_AT.res
 coll/de__PHONEBOOK.res
+coll/de_.res
+coll/de.res
 coll/el.res
 coll/en.res
 coll/en_US.res
-coll/es.res
 coll/es_.res
+coll/es.res
 coll/es__TRADITIONAL.res
 coll/et.res
 coll/fa.res
-coll/fi.res
 coll/fil.res
-coll/fr.res
+coll/fi.res
 coll/fr_CA.res
+coll/fr.res
 coll/gu.res
-coll/he.res
 coll/he_IL.res
+coll/he.res
 coll/hi.res
 coll/hr.res
 coll/hu.res
-coll/id.res
 coll/id_ID.res
-coll/in.res
+coll/id.res
 coll/in_ID.res
+coll/in.res
 coll/it.res
-coll/iw.res
 coll/iw_IL.res
+coll/iw.res
 coll/ja.res
 coll/kn.res
 coll/ko.res
@@ -46,50 +47,52 @@
 coll/mo.res
 coll/mr.res
 coll/ms.res
-coll/nb.res
 coll/nb_NO.res
+coll/nb.res
 coll/nn.res
-coll/no.res
 coll/no_NO.res
+coll/no.res
 coll/pl.res
-coll/ro.res
+coll/pt.res
 coll/ro_MD.res
+coll/ro.res
 coll/ru.res
-coll/sh.res
 coll/sh_BA.res
 coll/sh_CS.res
+coll/sh.res
 coll/sh_YU.res
 coll/sk.res
 coll/sl.res
-coll/sr.res
 coll/sr_BA.res
-coll/sr_Cyrl.res
 coll/sr_Cyrl_BA.res
 coll/sr_Cyrl_ME.res
+coll/sr_Cyrl.res
 coll/sr_Cyrl_RS.res
-coll/sr_Latn.res
 coll/sr_Latn_BA.res
+coll/sr_Latn.res
 coll/sr_Latn_RS.res
 coll/sr_ME.res
+coll/sr.res
 coll/sr_RS.res
 coll/sv.res
+coll/sw.res
 coll/ta.res
 coll/te.res
 coll/th.res
 coll/tr.res
 coll/uk.res
 coll/vi.res
-coll/zh.res
 coll/zh_CN.res
-coll/zh_HK.res
-coll/zh_Hans.res
 coll/zh_Hans_CN.res
+coll/zh_Hans.res
 coll/zh_Hans_SG.res
-coll/zh_Hant.res
 coll/zh_Hant_HK.res
 coll/zh_Hant_MO.res
+coll/zh_Hant.res
 coll/zh_Hant_TW.res
+coll/zh_HK.res
 coll/zh_MO.res
+coll/zh.res
 coll/zh_SG.res
 coll/zh_TW.res
 
@@ -108,16 +111,16 @@
 brkitr/ru.res
 brkitr/sent_el.brk
 brkitr/word_ja.brk
+
 curr/am.res
 curr/ar.res
 curr/bg.res
 curr/ca.res
 curr/cs.res
 curr/da.res
-curr/de.res
 curr/de_CH.res
+curr/de.res
 curr/el.res
-curr/en.res
 curr/en_001.res
 curr/en_150.res
 curr/en_AU.res
@@ -127,18 +130,19 @@
 curr/en_IN.res
 curr/en_NG.res
 curr/en_NZ.res
+curr/en.res
 curr/en_SG.res
 curr/en_ZA.res
-curr/es.res
 curr/es_419.res
 curr/es_AR.res
 curr/es_MX.res
+curr/es.res
 curr/es_US.res
 curr/fa.res
-curr/fi.res
 curr/fil.res
-curr/fr.res
+curr/fi.res
 curr/fr_CA.res
+curr/fr.res
 curr/he.res
 curr/hi.res
 curr/hr.res
@@ -155,8 +159,8 @@
 curr/nl.res
 curr/no.res
 curr/pl.res
-curr/pt.res
 curr/pt_PT.res
+curr/pt.res
 curr/res_index.res
 curr/ro.res
 curr/ru.res
@@ -171,15 +175,15 @@
 curr/tr.res
 curr/uk.res
 curr/vi.res
-curr/zh.res
 curr/zh_CN.res
-curr/zh_HK.res
-curr/zh_Hans.res
 curr/zh_Hans_CN.res
+curr/zh_Hans.res
 curr/zh_Hans_SG.res
-curr/zh_Hant.res
 curr/zh_Hant_HK.res
+curr/zh_Hant.res
 curr/zh_Hant_TW.res
+curr/zh_HK.res
+curr/zh.res
 curr/zh_SG.res
 curr/zh_TW.res
 
@@ -188,8 +192,8 @@
 unit/am.res
 unit/ar.res
 unit/az.res
-unit/be.res
 unit/bem.res
+unit/be.res
 unit/bg.res
 unit/bn.res
 unit/br.res
@@ -198,11 +202,10 @@
 unit/cs.res
 unit/cy.res
 unit/da.res
-unit/de.res
 unit/de_CH.res
+unit/de.res
 unit/ee.res
 unit/el.res
-unit/en.res
 unit/en_001.res
 unit/en_150.res
 unit/en_AU.res
@@ -210,22 +213,23 @@
 unit/en_GB.res
 unit/en_IN.res
 unit/en_NZ.res
+unit/en.res
 unit/en_US.res
 unit/en_ZA.res
 unit/eo.res
-unit/es.res
 unit/es_419.res
 unit/es_AR.res
-unit/es_US.res
 unit/es_MX.res
+unit/es.res
+unit/es_US.res
 unit/et.res
 unit/eu.res
 unit/fa.res
-unit/fi.res
 unit/fil.res
+unit/fi.res
 unit/fo.res
-unit/fr.res
 unit/fr_CA.res
+unit/fr.res
 unit/ga.res
 unit/gl.res
 unit/gu.res
@@ -275,13 +279,13 @@
 unit/pa.res
 unit/pl.res
 unit/ps.res
-unit/pt.res
 unit/pt_PT.res
+unit/pt.res
 unit/res_index.res
 unit/rm.res
 unit/rn.res
-unit/ro.res
 unit/ro_MD.res
+unit/ro.res
 unit/ru.res
 unit/rw.res
 unit/sh.res
@@ -291,8 +295,8 @@
 unit/sn.res
 unit/so.res
 unit/sq.res
-unit/sr.res
 unit/sr_Latn.res
+unit/sr.res
 unit/sv.res
 unit/sw.res
 unit/ta.res
@@ -307,41 +311,64 @@
 unit/uz.res
 unit/vi.res
 unit/yo.res
-unit/zh.res
 unit/zh_CN.res
-unit/zh_HK.res
-unit/zh_Hans.res
 unit/zh_Hans_CN.res
+unit/zh_Hans.res
 unit/zh_Hans_SG.res
-unit/zh_Hant.res
 unit/zh_Hant_HK.res
+unit/zh_Hant.res
 unit/zh_Hant_TW.res
+unit/zh_HK.res
+unit/zh.res
 unit/zh_SG.res
 unit/zh_TW.res
 unit/zu.res
+
+lang/ar_EG.res
+lang/ar_LY.res
+lang/ar_SA.res
+lang/de_AT.res
+lang/de_CH.res
+lang/en_001.res
+lang/en_AU.res
+lang/en_CA.res
+lang/en_IN.res
+lang/en_NZ.res
+lang/fr_CA.res
+lang/fr_CH.res
+region/fr_CA.res
+
 ar_001.res
 ar_AE.res
 ar_BH.res
 ar_DJ.res
+ar_DZ.res
 ar_EG.res
+ar_EH.res
 ar_ER.res
 ar_IL.res
 ar_IQ.res
 ar_JO.res
 ar_KM.res
 ar_KW.res
+ar_LB.res
+ar_LY.res
+ar_MA.res
+ar_MR.res
 ar_OM.res
 ar_PS.res
 ar_QA.res
+ar_SA.res
 ar_SD.res
+ar_SO.res
 ar_SS.res
 ar_SY.res
 ar_TD.res
+ar_TN.res
 ar_YE.res
-coll/am.res
-coll/pt.res
-coll/sw.res
+de_AT.res
 de_BE.res
+de_CH.res
 de_IT.res
 de_LI.res
 de_LU.res
@@ -378,6 +405,7 @@
 en_GM.res
 en_GU.res
 en_GY.res
+en_HK.res
 en_IE.res
 en_IL.res
 en_IM.res
@@ -406,6 +434,7 @@
 en_NL.res
 en_NR.res
 en_NU.res
+en_NZ.res
 en_PG.res
 en_PH.res
 en_PK.res
@@ -417,6 +446,7 @@
 en_SC.res
 en_SD.res
 en_SE.res
+en_SG.res
 en_SH.res
 en_SI.res
 en_SL.res
@@ -437,16 +467,42 @@
 en_VI.res
 en_VU.res
 en_WS.res
+en_ZA.res
 en_ZM.res
 en_ZW.res
+es_BO.res
+es_BR.res
+es_BZ.res
+es_CL.res
+es_CO.res
+es_CR.res
+es_CU.res
+es_DO.res
+es_EA.res
+es_EC.res
+es_GQ.res
+es_GT.res
+es_HN.res
+es_IC.res
+es_NI.res
+es_PA.res
+es_PE.res
+es_PH.res
+es_PR.res
+es_PY.res
+es_SV.res
+es_UY.res
+es_VE.res
 fr_BE.res
 fr_BF.res
 fr_BI.res
 fr_BJ.res
 fr_BL.res
+fr_CA.res
 fr_CD.res
 fr_CF.res
 fr_CG.res
+fr_CH.res
 fr_CI.res
 fr_CM.res
 fr_DJ.res
@@ -483,18 +539,6 @@
 fr_VU.res
 fr_WF.res
 fr_YT.res
-lang/ar_EG.res
-lang/ar_LY.res
-lang/ar_SA.res
-lang/de_AT.res
-lang/de_CH.res
-lang/en_001.res
-lang/en_AU.res
-lang/en_CA.res
-lang/en_IN.res
-lang/en_NZ.res
-lang/fr_CA.res
-lang/fr_CH.res
 nl_AW.res
 nl_BE.res
 nl_BQ.res
@@ -512,7 +556,6 @@
 pt_MZ.res
 pt_ST.res
 pt_TL.res
-region/fr_CA.res
 ru_BY.res
 ru_KG.res
 ru_KZ.res
diff --git a/cast/icudtl.dat b/cast/icudtl.dat
index 08e4238..0f0c636 100644
--- a/cast/icudtl.dat
+++ b/cast/icudtl.dat
Binary files differ
diff --git a/cast/patch_locale.sh b/cast/patch_locale.sh
index 91ff109..286bd49 100755
--- a/cast/patch_locale.sh
+++ b/cast/patch_locale.sh
@@ -82,11 +82,32 @@
      /^\}$/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.
@@ -117,20 +138,31 @@
       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=''
       ;;
@@ -152,4 +184,16 @@
           }' -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.
diff --git a/common/icudtb.dat b/common/icudtb.dat
index 592186c..8cbc444 100644
--- a/common/icudtb.dat
+++ b/common/icudtb.dat
Binary files differ
diff --git a/common/icudtl.dat b/common/icudtl.dat
index 7638b72..4090138 100644
--- a/common/icudtl.dat
+++ b/common/icudtl.dat
Binary files differ
diff --git a/flutter/icudtl.dat b/flutter/icudtl.dat
index 03e3eb6..3469eef 100644
--- a/flutter/icudtl.dat
+++ b/flutter/icudtl.dat
Binary files differ
diff --git a/ios/icudtl.dat b/ios/icudtl.dat
index f709216..64b26b4 100644
--- a/ios/icudtl.dat
+++ b/ios/icudtl.dat
Binary files differ
diff --git a/scripts/trim_data.sh b/scripts/trim_data.sh
index 7003fcc..b172ad5 100755
--- a/scripts/trim_data.sh
+++ b/scripts/trim_data.sh
@@ -17,7 +17,12 @@
        /^    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 \