Skip to content

Commit

Permalink
locale/gettext.sh: Refactor duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
reedy committed Jan 3, 2024
1 parent ee01280 commit b56d59d
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions locale/gettext.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@
# Should be run from repo root; ./locale/gettext.sh
#

PHP="about.php data.php donate.php faq.php index.php sidebar.php help/*php html/*php php/*php"
JS="openflights.js js/alsearch.js js/apsearch.js js/functions.js js/settings.js js/trip.js"
OPTS="--omit-header --no-location --no-wrap -j"

for lang in de_DE en_GB en_US es_ES fi_FI fr_FR ja_JP lt_LT nl_NL pl_PL pt_BR sv_SE ru_RU; do
PO_PATH=locale/$lang.utf8/LC_MESSAGES
echo $lang

PO_NEW=$PO_PATH/new.po
buildlocale() {
PO_NEW=$1/new.po
touch $PO_NEW

xgettext $OPTS -o $PO_NEW $PHP
Expand All @@ -25,17 +18,22 @@ for lang in de_DE en_GB en_US es_ES fi_FI fr_FR ja_JP lt_LT nl_NL pl_PL pt_BR sv
PO_MESSAGES=$PO_PATH/messages.po

msgmerge -N $PO_MESSAGES $PO_NEW >$PO_NEWEST
grep -v ^#~ $PO_NEWEST >$PO_MESSAGES
grep -v "^#~" $PO_NEWEST >$PO_MESSAGES
rm $PO_NEW $PO_NEWEST

# Make .mo files
MO_FILE=$PO_PATH/messages.mo
msgfmt -o $MO_FILE $PO_MESSAGES
}

PHP="about.php data.php donate.php faq.php index.php sidebar.php help/*php html/*php php/*php"
JS="openflights.js js/alsearch.js js/apsearch.js js/functions.js js/settings.js js/trip.js"
OPTS="--omit-header --no-location --no-wrap -j"

for lang in de_DE en_GB en_US es_ES fi_FI fr_FR ja_JP lt_LT nl_NL pl_PL pt_BR sv_SE ru_RU; do
echo $lang
PO_PATH=locale/$lang.utf8/LC_MESSAGES
buildlocale $PO_PATH
done

touch locale/new.po
xgettext $OPTS -o locale/template.pot $PHP
xgettext $OPTS -L C -o locale/template.pot $JS
msgmerge -N locale/template.pot locale/new.po >locale/newest.po
grep -v "^#~" locale/newest.po >locale/messages.po
rm locale/new.po locale/newest.po
buildlocale locale

0 comments on commit b56d59d

Please sign in to comment.