forked from elixir-cldr/cldr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ldml2json
executable file
·73 lines (57 loc) · 2.57 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
#! /bin/zsh
# The location of the `ex_cldr` repo
export EX_CLDR="$HOME/Development/cldr"
[ ! -d $EX_CLDR ] && { echo "ex_cldr repository $BAK was not found."; exit 1; }
# The location of the cloned CLDR repo
export CLDR_REPO="$HOME/Development/cldr_repo"
[ ! -d $CLDR_REPO ] && { echo "CLDR repository $CLDR_REPO was not found."; exit 1; }
# Location of where the staging data should
# be provisioned
export CLDR_STAGING="$HOME/Development/cldr_staging_data"
[ ! -d $CLDR_STAGING ] && { echo "CLDR staging directory $CLDR_STAGING was not found."; exit 1; }
# Location where the production data will be
# provisioined.
export CLDR_PRODUCTION="$HOME/Development/cldr_production_data"
[ ! -d $CLDR_PRODUCTION ] && { echo "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_TOOLS="$CLDR_REPO/tools/java/cldr.jar"
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
# verison does not). Therefore the working aproach 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
# ex_cldr additional data required for data generation
cp $EX_CLDR/data/measurement_systems.xml $CLDR_PRODUCTION/measurement_systems.xml
cp $EX_CLDR/data/iso_currencies.xml $CLDR_PRODUCTION/iso_currencies.xml
cd $OLDPWD