]> Frank Brehm's Git Trees - pixelpark/puppet-tools.git/commitdiff
Adding compile-xlate-msgs.sh and xtract-xlate-msgs.sh
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 15 Feb 2023 14:41:17 +0000 (15:41 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 15 Feb 2023 14:41:17 +0000 (15:41 +0100)
compile-xlate-msgs.sh [new file with mode: 0755]
lib/dpx_puppettools/app/__init__.py
lib/dpx_puppettools/app/get_forge_module.py
xtract-xlate-msgs.sh [new file with mode: 0755]

diff --git a/compile-xlate-msgs.sh b/compile-xlate-msgs.sh
new file mode 100755 (executable)
index 0000000..3b25350
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+set -e
+set -u
+
+base_dir=$( dirname "$0" )
+cd "${base_dir}" ||exit 99
+
+locale_dir="locale"
+locale_domain="dpx_puppettools"
+# pot_file="${locale_dir}/${locale_domain}.pot"
+# po_with="99"
+# my_address="${DEBEMAIL:-frank@brehm-online.com}"
+
+pybabel compile --domain "${locale_domain}" \
+    --directory "${locale_dir}" \
+    --statistics
+
index 9d48a6c7115ef6e538f9a9cdaf9146bd5ccdf6e0..31a44dc3d65a0e294222bd158ab0a6a1a252730d 100644 (file)
@@ -176,7 +176,7 @@ class BaseDPXPuppetApplication(FbConfigApplication):
         help_txt = _(
             "The directory containing variable data from DPX puppet tools. "
             "Cache files for the forge information are read and written from the sub "
-            "directory {fd!r} below it. iCaching Git repositories are cloned in the "
+            "directory {fd!r} below it. Caching Git repositories are cloned in the "
             "sub directory {gd!r} below it. Default: {vd!r}.").format(
             vd=str(DpxPuppetConfig.default_var_dir), fd='forge', gd='git')
         puppet_group.add_argument(
@@ -238,7 +238,7 @@ class BaseDPXPuppetApplication(FbConfigApplication):
             '--mail-server',
             metavar=_("SERVER"), dest="mail_server",
             help=_(
-                "Mail server for submitting generated by this script if "
+                "Mail server for submitting mails generated by this script if "
                 "the mail method of this script is 'smtp'. Default: {!r}.").format(mail_server)
         )
 
index ecaabee3300279249b652c9a4e947995520dc9bb..0cd108c5cb5202c619385fc304800967cd482705 100644 (file)
@@ -64,7 +64,7 @@ class GetForgeModuleApplication(BaseDPXPuppetApplication):
         self.mod_env_info = {}
 
         self._force_desc_msg = _(
-            "Write the cache file also, if the data was successful read from chache file.")
+            "Write the cache file also, if the data was successful read from cache file.")
 
         desc = _(
             "This application retrieves information about the given module "
diff --git a/xtract-xlate-msgs.sh b/xtract-xlate-msgs.sh
new file mode 100755 (executable)
index 0000000..70d5159
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+set -e
+set -u
+
+base_dir=$( dirname "$0" )
+cd "${base_dir}" || exit 99
+
+locale_dir="locale"
+locale_domain="dpx_puppettools"
+pot_file="${locale_dir}/${locale_domain}.pot"
+po_with="99"
+my_address="${DEBEMAIL:-frank.brehm@pixelpark.com}"
+
+pkg_version=$( grep -E '^\s*__version__'  lib/dpx_puppettools/__init__.py| sed -e 's/.*=[  ]*//' -e "s/'//g" )
+echo "Package-Version: '${pkg_version}'"
+
+pybabel extract bin/* lib \
+    -o "${pot_file}" \
+    -F etc/babel.ini \
+    --width=${po_with} \
+    --sort-by-file \
+    --msgid-bugs-address="${my_address}" \
+    --copyright-holder="Frank Brehm, Digitas Pixelpark Berlin" \
+    --project="${locale_domain}" \
+    --version="${pkg_version}"
+
+sed -i -e "s/FIRST AUTHOR/Frank Brehm/g" -e "s/<EMAIL@ADDRESS>/<${my_address}>/g" "${pot_file}"
+
+for lang in de_DE en_US ; do
+    po_file="${locale_dir}/${lang}/LC_MESSAGES/${locale_domain}.po"
+    if [[ ! -f "${po_file}" ]] ; then
+        pybabel init --domain "${locale_domain}" \
+            --input-file "${pot_file}" \
+            --output-dir "${locale_dir}" \
+            --locale "${lang}" \
+            --width ${po_with}
+    else
+        pybabel update --domain "${locale_domain}" \
+            --input-file "${pot_file}" \
+            --output-dir "${locale_dir}" \
+            --locale "${lang}" \
+            --width ${po_with} \
+            --ignore-obsolete \
+            --update-header-comment
+    fi
+
+    # Updating project version
+    sed -i -e "s/^\(\"Project-Id-Version:[     ][      ]*[^    ][^     ]*[     ][      ]*\)[^  \\][^   \\]*/\1${pkg_version}/i" "${po_file}"
+
+done
+
+# vim: ts=4 list