From 0e9176f96026771157d2803072f63c8ed3eb32de Mon Sep 17 00:00:00 2001 From: erciccione Date: Sun, 25 Jul 2021 12:45:02 +0200 Subject: [PATCH] new structure for managing language files of the user guides now there are multiple config files in /po, that will be parsed by the po-update.sh script, which runs po4a on each config file. The .config file updates both .po/.pot files and the actual guides (.md). See the script for more details. --- po/monero-wallet-cli.config | 13 ++++++++ po/po-update.sh | 47 +++++++++++++++++++++++++++ po/verification-allos-advanced.config | 13 ++++++++ po4a.config | 27 --------------- 4 files changed, 73 insertions(+), 27 deletions(-) create mode 100644 po/monero-wallet-cli.config create mode 100755 po/po-update.sh create mode 100644 po/verification-allos-advanced.config delete mode 100644 po4a.config diff --git a/po/monero-wallet-cli.config b/po/monero-wallet-cli.config new file mode 100644 index 00000000..2e66b70c --- /dev/null +++ b/po/monero-wallet-cli.config @@ -0,0 +1,13 @@ +[po4a_langs] es it pl fr ar ru de nl pt-br tr zh-cn zh-tw nb-no +[po4a_paths] ../_i18n/en/resources/user-guides/weblate/monero-wallet-cli.pot $lang:../_i18n/$lang/resources/user-guides/weblate/monero-wallet-cli.po + +[options] opt:"--keep=0" +[options] opt:"--localized-charset=UTF-8" +[options] opt:"--master-charset=UTF-8" +[options] opt:"--master-language=en_US" +[options] opt:"--msgmerge-opt='--no-wrap'" +[options] opt:"--wrap-po=newlines" + +[po4a_alias:markdown] text opt:"--option markdown" + +[type: markdown] ../_i18n/en/resources/user-guides/monero-wallet-cli.md $lang:../_i18n/$lang/resources/user-guides/monero-wallet-cli.md \ No newline at end of file diff --git a/po/po-update.sh b/po/po-update.sh new file mode 100755 index 00000000..e7b1d50e --- /dev/null +++ b/po/po-update.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# SCRIPT +# +# This script loops through all the .config files in this folder and run po4a on them. The config files are one for each user guide. +# See the next section for instructions about adding new config files. +# +# CONFIG FILES +# +# The config files give a set of instructions to po4a, which will update all translations files (.pot and .po) and documents (.md) at the same time. +# we use --keep=0 to transfer all translated content directly to the original markdown file, but would be good to switch to a more reasonable thresold +# (maybe the standard 80%?) in the future, when the guides will be mostly translated. +# +# To avoid spamming unnecessary diffs, we didn't add all config files for all guides. A new config file should be added +# when the translation files and the guides themselves need to be updated (so, when the original document got changed and +# the changes need to be transferred to the translation files). To add a new config file to be managed by po4a: +# +# 1. Copy one of the other .config files and rename it to the filename of the guide it's going to point to (for example, for the user guide +# 'verification-allos-advanced.md' we will create a config file named 'verification-allos-advanced.config'). +# 2.change the strings starting with [po4a_paths] and [type: markdown] using this structure: +# [po4a_paths] ../_i18n/en/resources/user-guides/weblate/ $lang:../_i18n/$lang/resources/user-guides/weblate/ +# 3. At the bottom of the file, change the '[type: markdown]' instruction: +# [type: markdown] ../_i18n/en/resources/user-guides/ $lang:../_i18n/$lang/resources/user-guides/ + +checkpo() { + if ! command -v po4a &> /dev/null + then + echo "po4a is not installed" + exit + else + echo "Updating language files.." + fi +} + +updatelangs() { + for guide in *.config; do + echo "-> Running po4a on ${guide}" + po4a $guide || echo "ERROR: something went wrong, po4a didn't run succesfully on ${guide}" + done +} + +while true; do + checkpo + updatelangs + echo "Done." + break +done diff --git a/po/verification-allos-advanced.config b/po/verification-allos-advanced.config new file mode 100644 index 00000000..fd4e83d9 --- /dev/null +++ b/po/verification-allos-advanced.config @@ -0,0 +1,13 @@ +[po4a_langs] es it pl fr ar ru de nl pt-br tr zh-cn zh-tw nb-no +[po4a_paths] ../_i18n/en/resources/user-guides/weblate/verification-allos-advanced.pot $lang:../_i18n/$lang/resources/user-guides/weblate/verification-allos-advanced.po + +[options] opt:"--keep=0" +[options] opt:"--localized-charset=UTF-8" +[options] opt:"--master-charset=UTF-8" +[options] opt:"--master-language=en_US" +[options] opt:"--msgmerge-opt='--no-wrap'" +[options] opt:"--wrap-po=newlines" + +[po4a_alias:markdown] text opt:"--option markdown" + +[type: markdown] ../_i18n/en/resources/user-guides/verification-allos-advanced.md $lang:../_i18n/$lang/resources/user-guides/verification-allos-advanced.md \ No newline at end of file diff --git a/po4a.config b/po4a.config deleted file mode 100644 index d3e6f006..00000000 --- a/po4a.config +++ /dev/null @@ -1,27 +0,0 @@ -# This config file gives a set of instructions to po4a, which will update all translations files (.pot and .po) and documents (.md) at the same time. -# we use --keep=0 to transfer all translated content directly to the original markdown file, but would be good to switch to a more reasonable thresold -# (maybe the standard 80%?) in the future, when the guides will be mostly translated. -# -# To avoid spamming unnecessary diffs, we don't add all guides managed by po4a at the same time. Guides should be added to this file -# when the translation files and the guides itself need to be updated (so when the original document got changed and the changes need to be transferred -# to the translation files). To add a new document to be managed by po4a: -# Under the last '[po4a_paths]' instruction add: -# [po4a_paths] _i18n/en/resources/user-guides/weblate/ $lang:_i18n/$lang/resources/user-guides/weblate/ -# At the bottom of the file, under the last '[type: markdown]' instruction, add: -# [type: markdown] _i18n/en/resources/user-guides/ $lang:_i18n/$lang/resources/user-guides/ -# -# To update the language files listed here and related documents run `po4a po4a.config` - -[po4a_langs] es it pl fr ar ru de nl pt-br tr zh-cn zh-tw nb-no -[po4a_paths] _i18n/en/resources/user-guides/weblate/verification-allos-advanced.pot $lang:_i18n/$lang/resources/user-guides/weblate/verification-allos-advanced.po - -[options] opt:"--keep=0" -[options] opt:"--localized-charset=UTF-8" -[options] opt:"--master-charset=UTF-8" -[options] opt:"--master-language=en_US" -[options] opt:"--msgmerge-opt='--no-wrap'" -[options] opt:"--wrap-po=newlines" - -[po4a_alias:markdown] text opt:"--option markdown" - -[type: markdown] _i18n/en/resources/user-guides/verification-allos-advanced.md $lang:_i18n/$lang/resources/user-guides/verification-allos-advanced.md \ No newline at end of file