|
| 1 | +#!/bin/bash |
| 2 | +# This script performs the following: |
| 3 | +# - Generate configuration file for po4a (can be configured in CONFIGFILE) |
| 4 | +# - Generate POT file from pages/<DIRECTORY>/*.md |
| 5 | +# - Update PO files in i18n directory with POT file |
| 6 | +# - Generate localized pages.XX/<DIRECTORY>/*.md (where XX is the language code) |
| 7 | +# - Remove unneeded new lines from generated pages |
| 8 | + |
| 9 | +# Name of the po4a configuration file |
| 10 | +CONFIGFILE='po4a.conf' |
| 11 | + |
| 12 | +# List of supported languages |
| 13 | +LANGS=(hu) |
| 14 | + |
| 15 | +# Generate po4a.conf file with list of TLDR pages |
| 16 | +echo 'Generating configuration file for po4a...' |
| 17 | + |
| 18 | +echo '# WARNING: this file is generated with translation-update.sh' > $CONFIGFILE |
| 19 | +echo '# DO NOT modify this file manually!' >> $CONFIGFILE |
| 20 | +echo -e >> $CONFIGFILE |
| 21 | +echo "[po4a_langs] ${LANGS[*]}" >> $CONFIGFILE |
| 22 | +echo '[po4a_paths] i18n/tldr.pot $lang:i18n/tldr.$lang.po' >> $CONFIGFILE |
| 23 | +echo -e >> $CONFIGFILE |
| 24 | +for FILE in `tree -f -i pages | grep ".md"` |
| 25 | +do |
| 26 | + echo [type: asciidoc] $FILE \$lang:pages.\$lang/`echo $FILE | cut -d"/" -f 2`/`echo $FILE | cut -d"/" -f 3` >> $CONFIGFILE |
| 27 | +done |
| 28 | + |
| 29 | +# Generate POT file, PO files, and pages.XX pages |
| 30 | +echo 'Generating POT file and translated TLDR pages...' |
| 31 | +po4a -k 0 --msgid-bugs-address 'https://github.com/tldr-pages/tldr/issues' po4a.conf |
| 32 | + |
| 33 | +# Beautify translated TLDR pages (remove unneeded new lines) |
| 34 | +for LANG in "${LANGS[@]}" |
| 35 | +do |
| 36 | + echo "Beautifying TLDR pages ($LANG)..." |
| 37 | + for FILE in `tree -f -i pages.$LANG | grep ".md"` |
| 38 | + do |
| 39 | + sed -i '/[^#|^>|^-|^`].*$/{$!N; s/\n / /g; }' $FILE |
| 40 | + done |
| 41 | +done |
0 commit comments