1 | PO=$(mktemp -d) |
---|
2 | |
---|
3 | log "Exporting PO files from GlotPress (wp/$GP_VER/$GP_LOCALE/$GP_TS_SLUG)..." |
---|
4 | $GP_EXPORT "wp/$GP_VER" $GP_LOCALE --set=$GP_TS_SLUG --status=current > $PO/$WP_LOCALE.po |
---|
5 | PO_1=$? |
---|
6 | $GP_EXPORT "wp/$GP_VER/admin" $GP_LOCALE --set=$GP_TS_SLUG --status=current > $PO/admin-$WP_LOCALE.po |
---|
7 | PO_2=$? |
---|
8 | $GP_EXPORT "wp/$GP_VER/admin/network" $GP_LOCALE --set=$GP_TS_SLUG --status=current > $PO/admin-network-$WP_LOCALE.po |
---|
9 | PO_3=$? |
---|
10 | if [ "${WP_LOCALE:0:3}" != "en_" ]; then |
---|
11 | $GP_EXPORT "wp/$GP_VER/cc" $GP_LOCALE --set=$GP_TS_SLUG --status=current > $PO/continents-cities-$WP_LOCALE.po |
---|
12 | PO_4=$? |
---|
13 | else |
---|
14 | PO_4=0 |
---|
15 | fi |
---|
16 | |
---|
17 | if [ $PO_1 -ne 0 ] || [ $PO_2 -ne 0 ] || [ $PO_3 -ne 0 ] || [ $PO_4 -ne 0 ]; then |
---|
18 | log "PO export failed." |
---|
19 | log "Exit codes: dev $PO_1, admin $PO_2, network $PO_3, cc $PO_4" |
---|
20 | ls -la $PO |
---|
21 | rm -r $PO |
---|
22 | exit 1 |
---|
23 | fi |
---|
24 | |
---|
25 | log "Generating MO files..." |
---|
26 | msgfmt $PO/$WP_LOCALE.po -o $PO/$WP_LOCALE.mo |
---|
27 | PO_1=$? |
---|
28 | msgfmt $PO/admin-$WP_LOCALE.po -o $PO/admin-$WP_LOCALE.mo |
---|
29 | PO_2=$? |
---|
30 | msgfmt $PO/admin-network-$WP_LOCALE.po -o $PO/admin-network-$WP_LOCALE.mo |
---|
31 | PO_3=$? |
---|
32 | if [ "${WP_LOCALE:0:3}" != "en_" ]; then |
---|
33 | msgfmt $PO/continents-cities-$WP_LOCALE.po -o $PO/continents-cities-$WP_LOCALE.mo |
---|
34 | PO_4=$? |
---|
35 | else |
---|
36 | PO_4=0 |
---|
37 | fi |
---|
38 | |
---|
39 | if [ $PO_1 -ne 0 ] || [ $PO_2 -ne 0 ] || [ $PO_3 -ne 0 ] || [ $PO_4 -ne 0 ]; then |
---|
40 | log "MO generation failed." |
---|
41 | log "Exit codes: dev $PO_1, admin $PO_2, network $PO_3, cc $PO_4" |
---|
42 | ls -la $PO |
---|
43 | rm -r $PO |
---|
44 | exit 1 |
---|
45 | fi |
---|
46 | |
---|
47 | log "Creating language pack..." |
---|
48 | zip -9 -j $PO/$WP_LOCALE.zip $PO/*.po $PO/*.mo > /dev/null # -j junks paths |
---|
49 | if [ "$?" -ne 0 ]; then |
---|
50 | rm -r $PO |
---|
51 | log "Language pack ZIP generation failed." |
---|
52 | exit 1 |
---|
53 | fi |
---|