aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/po
diff options
context:
space:
mode:
authorWolfgang Müller2021-06-28 18:06:50 +0200
committerWolfgang Müller2021-06-29 11:38:43 +0200
commit124fc81ddc15b3984a5f08744f7e3d69528b8213 (patch)
tree21153b2f88316dde0e3957417970fbdf500d28ed /po
parentd7553f65c1e9b0c5eeded77a2ce7eb521b315f62 (diff)
downloadweltschmerz-124fc81ddc15b3984a5f08744f7e3d69528b8213.tar.gz
Use custom scripts instead of meson's gettext tooling
meson's tooling for gettext introduces a couple of issues. Firstly, it is currently not possible [1] to specify per-language keywords. We need this in order to ignore the 'Name' record in the desktop file. Secondly, every invocation of 'update-po' also updates the pot file [2], inadvertently recording the updated creation date in all translations. Since we recommended the use of 'update-po' to translators in TRANSLATE, this will lead to lots of unrelated changes every time a new translation is added, even if no msgids change. Thirdly, people who do not have meson installed are currently not able to use the tooling it provides. To fix these issues, this commit adds custom tooling around gettext: The 'update-pot.sh' script updates the pot and po files using xgettext(1) and msgmerge(1), and 'init-po.sh' makes the necessary changes to LINGUAS whilst also creating the relevant po file(s) with msginit(1). We no longer need to refer to meson at all in TRANSLATE. Make sure to mention the new scripts as well. [1] https://github.com/mesonbuild/meson/issues/1739 [2] https://github.com/mesonbuild/meson/blob/a9e9b7c7501a3c8a5984a93879d1f309bf8c72aa/mesonbuild/scripts/gettext.py#L112
Diffstat (limited to 'po')
-rw-r--r--po/POTFILES1
-rw-r--r--po/init-po.sh8
-rw-r--r--po/meson.build4
-rw-r--r--po/update-pot.sh16
4 files changed, 25 insertions, 4 deletions
diff --git a/po/POTFILES b/po/POTFILES
index 107469c..4d9f89d 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -1,4 +1,3 @@
configreader.vala
terminal.ui
terminal.vala
-weltschmerz.desktop.in
diff --git a/po/init-po.sh b/po/init-po.sh
new file mode 100644
index 0000000..0830875
--- /dev/null
+++ b/po/init-po.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+lang=$1
+
+echo "$lang" >> po/LINGUAS
+sort -u po/LINGUAS -o po/LINGUAS
+
+msginit -i po/weltschmerz.pot -o "po/${lang}.po" --locale "$lang" --no-translator
diff --git a/po/meson.build b/po/meson.build
index 5cbb15b..6870f58 100644
--- a/po/meson.build
+++ b/po/meson.build
@@ -4,6 +4,4 @@ localedir = join_paths(get_option('prefix'), get_option('localedir'))
add_project_arguments('-DGETTEXT_PACKAGE="weltschmerz"', language: 'c')
add_project_arguments('-DLOCALEDIR="@0@"'.format(localedir), language: 'c')
-i18n.gettext(meson.project_name(),
- args: ['--directory=' + meson.source_root(), '-c TRANSLATORS', '--from-code=UTF-8']
-)
+i18n.gettext(meson.project_name(), args: '--directory=' + meson.source_root())
diff --git a/po/update-pot.sh b/po/update-pot.sh
new file mode 100644
index 0000000..6ceb21f
--- /dev/null
+++ b/po/update-pot.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+_xgettext() {
+ xgettext --package-name=weltschmerz -cTRANSLATORS "$@" -o po/weltschmerz.pot
+}
+
+_xgettext -f po/POTFILES
+
+# We treat this file specially in order to override the keywords used for it.
+# Since we do not want Name translated, reset the keyword list with -k and then
+# add the keywords we want.
+_xgettext -j -k -kComment -kKeywords weltschmerz.desktop.in
+
+while read lang; do
+ msgmerge -q -o "po/${lang}.po" "po/${lang}.po" po/weltschmerz.pot
+done < po/LINGUAS