-
Notifications
You must be signed in to change notification settings - Fork 36
/
ldml2json
executable file
·102 lines (79 loc) · 3.71 KB
/
ldml2json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#! /bin/zsh
# The location of the `ex_cldr` repo
export EX_CLDR="${EX_CLDR:=$HOME/Development/cldr}"
[ ! -d $EX_CLDR ] && { echo "ex_cldr repository $EX_CLDR was not found."; exit 1; }
# The location of the cloned CLDR repo
export CLDR_REPO="${CLDR_REPO:=$HOME/Development/cldr_repo}"
[ ! -d $CLDR_REPO ] && { echo "Unicode CLDR repository $CLDR_REPO was not found."; exit 1; }
# Location of where the staging data should
# be provisioned.
export CLDR_STAGING="${CLDR_STAGING:=$HOME/Development/cldr_staging_data}"
[ ! -d $CLDR_STAGING ] && { echo "Unicode CLDR staging directory $CLDR_STAGING was not found."; exit 1; }
mkdir -p $CLDR_STAGING/seed/main
# Location where the production data will be
# provisioned.
export CLDR_PRODUCTION="${CLDR_PRODUCTION:=$HOME/Development/cldr_production_data}"
[ ! -d $CLDR_PRODUCTION ] && { echo "Unicode CLDR production directory $CLDR_PRODUCTION was not found."; exit 1; }
# The location of the CLDR utilities jar
# This location is autogenerated and should not need to
# be adjusted
export CLDR_CODE_DIR="$CLDR_REPO"
export CLDR_TOOLS="$CLDR_CODE_DIR/tools/cldr-code/target/cldr-code.jar"
# Rebuild the tools
cd $CLDR_CODE_DIR
mvn package -pl cldr-code --file=tools/pom.xml -DskipTests=true
cd $CLDR_REPO
# Expand to production data which will go in
# $CLDR_STAGING
java -DCLDR_DIR=$CLDR_REPO \
-jar $CLDR_TOOLS org.unicode.cldr.tool.GenerateProductionData \
-s $CLDR_REPO/common \
-d $CLDR_STAGING/common
# We do this since processing all locales in a single run
# reliably emits all locales (the consolidated
# version does not). Therefore the working approach is to
# do the following first
# for FULLPATH in $CLDR_REPO/common/main/*.xml; do
# LOCALE=$FULLPATH:t:r
# java -DCLDR_DIR=$CLDR_STAGING \
# -jar $CLDR_TOOLS ldml2json \
# -d $CLDR_PRODUCTION -p true -r true -t main -m $LOCALE
# done
# Data will be generated into $CLDR_PRODUCTION
# -Xmx16g may be too much but the default is definitely too small
# and will cause an out of heap memory exception
java -Xmx16g -DCLDR_DIR=$CLDR_STAGING \
-jar $CLDR_TOOLS ldml2json \
-d $CLDR_PRODUCTION -p true -r true -t
java -DCLDR_DIR=$CLDR_STAGING \
-jar $CLDR_TOOLS ldml2json \
-d $CLDR_PRODUCTION -p true -r true -t supplemental
java -DCLDR_DIR=$CLDR_STAGING \
-jar $CLDR_TOOLS ldml2json \
-d $CLDR_PRODUCTION -p true -r true -t rbnf
# Some data we process directly from the XML
cp $CLDR_REPO/common/supplemental/units.xml $CLDR_PRODUCTION
cp $CLDR_REPO/common/supplemental/pluralRanges.xml $CLDR_PRODUCTION/plural_ranges.xml
cp $CLDR_REPO/common/supplemental/subdivisions.xml $CLDR_PRODUCTION
cp $CLDR_REPO/common/bcp47/timezone.xml $CLDR_PRODUCTION/timezones.xml
mkdir -p $CLDR_PRODUCTION/subdivisions
cp $CLDR_STAGING/common/subdivisions/* $CLDR_PRODUCTION/subdivisions
# Validity data for language, script and territory
mkdir -p $CLDR_PRODUCTION/validity
cp -R $CLDR_REPO/common/validity/ $CLDR_PRODUCTION/validity/
# BCP 47 data for validating U and T extension values
mkdir -p $CLDR_PRODUCTION/bcp47
cp -R $CLDR_REPO/common/bcp47/ $CLDR_PRODUCTION/bcp47/
# ex_cldr additional data required for data generation
cp $EX_CLDR/data/iso_currencies.xml $CLDR_PRODUCTION/iso_currencies.xml
# Data that maps from Unicode script names to Script code (subtag)
cp $CLDR_REPO/tools/cldr-code/src/main/resources/org/unicode/cldr/util/data/Script_Metadata.csv \
$EX_CLDR/priv/cldr/script_metadata.csv
# Copy test data
cp $CLDR_REPO/common/testData/localeIdentifiers/localeCanonicalization.txt \
$EX_CLDR/test/data/locale_canonicalization.txt
cp $CLDR_REPO/common/testData/units/unitPreferencesTest.txt \
$EX_CLDR/test/data/preference_test_data.txt
cp $CLDR_REPO/common/testData/units/unitsTest.txt \
$EX_CLDR/test/data/conversion_test_data.txt
cd $OLDPWD