diff options
author | Guillaume GARDET <guillaume.gardet@free.fr> | 2015-01-14 16:25:58 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-01-15 07:34:17 +1300 |
commit | b4b08bdcc583efe9fcca4f8e5605606a8906ea12 (patch) | |
tree | 8b6e9578f386f8e859d82766cae6cdede55f91a8 /Documentation/make_PO_to_ASCIIDOC.sh | |
parent | 501f72c6976da0893d4e5f9bb82378e41c37f756 (diff) | |
download | subsurface-b4b08bdcc583efe9fcca4f8e5605606a8906ea12.tar.gz |
Add POT/PO infrastructure to translate user manual.
Signed-off-by: Guillaume GARDET <guillaume.gardet@free.fr>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'Documentation/make_PO_to_ASCIIDOC.sh')
-rwxr-xr-x | Documentation/make_PO_to_ASCIIDOC.sh | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/Documentation/make_PO_to_ASCIIDOC.sh b/Documentation/make_PO_to_ASCIIDOC.sh new file mode 100755 index 000000000..95fbf40ab --- /dev/null +++ b/Documentation/make_PO_to_ASCIIDOC.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# +# Author(s): Guillaume GARDET <guillaume.gardet@free.fr> +# +# History: +# - 2015-01-14: Initial release +# +# Known bugs: +# - Some list item indexes are lost during PO to ASCII conversion (see asciidoc warning messages) +# +# Package deps: - po4a (for po4a-translate) +# - git (for git sync) +# - gettext-tools (for msginit and msgmerge) + +# Some vars +File_to_translate="./user-manual.txt" +POT_files_folder="./50-pot/" +langs="fr" # Language list which uses POT/PO files for translation +PO_filename_root="subsurface-manual" +translation_limit="0" # Minimal translation percentage. Under this limit, no translated file is output. +dosync=1 # whether to pull new translations from git + +for i in "$@"; do + if [ "$i" = "--nosync" ]; then + dosync=0 + fi +done + +for lang in $langs; do + PO_folder="$lang/po" + +# Sync PO files from GIT server and update it using latest generated POT file (in case PO file not merged with latest POT) + if [ "$dosync" = 1 ]; then + echo "* Syncing PO file for '$lang'" + git pull + + for file in $(ls $POT_files_folder/*.pot); do + filename=$(basename ${file%.pot}).$lang.po + if [ ! -f $PO_folder/$filename ]; then + echo "** Initializing PO file for $lang" + mkdir -p $PO_folder + msginit -l $lang --input=$file --output-file=$PO_folder/$filename + fi; + echo "** Updating PO file for '$lang' from POT file" + msgmerge --previous --lang=$lang --update $PO_folder/$filename $POT_files_folder/*.pot + done + fi + +# Generate translated ASCIIDOC files + echo "* Generating ASCIIDOC files for '$lang'" + + for file in $File_to_translate; do + Translated_file=$(basename ${File_to_translate%.txt})_$lang.txt + cmd="po4a-translate --keep $translation_limit -f asciidoc -M UTF-8 -m $File_to_translate -p $PO_folder/$PO_filename_root.$lang.po -l $Translated_file" + echo $cmd + $cmd + done + +done |