From 2daf0c28c8e79d68db8b80be31a98e52244ede70 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= <jn.avila@free.fr>
Date: Sun, 27 Jan 2019 14:32:00 +0100
Subject: [PATCH] Create list of translation in po4a.conf
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Instead of requiring the script file to contain the list of
translations, just extract it from the list of po files on the
filesystem.

Signed-off-by: Jean-No챘l Avila <jn.avila@free.fr>
---
 Makefile                    |  4 ++--
 README                      | 19 +++++++++----------
 scripts/create_po4a_conf.sh | 11 +++++++++--
 3 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/Makefile b/Makefile
index 2fa6fd2..3940967 100644
--- a/Makefile
+++ b/Makefile
@@ -15,8 +15,8 @@ ifndef V
 endif
 endif
 
-po4a.conf: scripts/create_po4a_conf.sh sources.txt
-	./scripts/create_po4a_conf.sh
+po4a.conf: scripts/create_po4a_conf.sh sources.txt $(LANGUAGE_PO)
+	@./scripts/create_po4a_conf.sh
 
 po4a-stamp: po4a.conf $(EN_SOURCES) $(LANGUAGE_PO) Makefile
 	$(QUIET_PO4A)PERL5LIB=./po4a/lib po4a/po4a -v po4a.conf
diff --git a/README b/README
index 62ddd98..1220bbc 100644
--- a/README
+++ b/README
@@ -97,15 +97,15 @@ Initializing a documentation.XX.po file
 If your language XX does not have translated message file
 documentation.XX.po yet, you add a translation for the first time by
 
- * editing the file create_po4a_conf.sh and adding your language code
-   to the first line, e.g. "[po4a_langs] fr XX", where XX is the
-   locale, such as "de", "is", "pt_BR", "zh_CN", etc.
- * running in the root directory of the project
-
-     make all
+ * initializing the translation po file by running:
+       msginit --local=XX
+   in the po/directory, where XX is the locale, e.g. "de", "is", "pt_BR",
+   "zh_CN", etc.
+ * pre-translating the file for unchanged strings by running:
+       scripts/pre-translate-po po/documentation.XX.po
 
 A file po/documentation.XX.po was created, corresponding
-to the newly created translation.
+to the newly created translation and is ready for your translations.
 
 Then edit the automatically generated copyright info in your new
 documentation.XX.po to be correct, e.g. for Icelandic:
@@ -126,8 +126,7 @@ just "Git Documentation":
     Documentation/' documentation.XX.po
 
 Once you are done testing the translation (see below), commit the
-create_po4a_conf.sh and documentation.XX.po files and ask the l10n coordinator
-to pull from you.
+documentation.XX.po files and ask the l10n coordinator to pull from you.
 
 Updating a documentation.XX.po file
 -----------------------------------
@@ -140,7 +139,7 @@ file.
 
 If there's an existing documentation.XX.po file for your language, but
 the repository of the l10n coordinator has newer documentation.pot
-file, chances are the new documentation.XX.po already includes the
+file, chances are the upstreamed documentation.XX.po already includes the
 changes of the new version.
 
 Once you are done testing the translation (see below), commit the result
diff --git a/scripts/create_po4a_conf.sh b/scripts/create_po4a_conf.sh
index ed74f09..ebb7adf 100755
--- a/scripts/create_po4a_conf.sh
+++ b/scripts/create_po4a_conf.sh
@@ -1,7 +1,14 @@
 #!/bin/bash
 
-cat <<EOF >po4a.conf
-[po4a_langs] fr de
+echo -n "[po4a_langs]" >po4a.conf
+for l in po/documentation.*.po
+do
+    rstripped=${l%%.po}
+    echo -n " ${rstripped##po/documentation.}" >> po4a.conf
+done
+echo >> po4a.conf
+
+cat <<EOF >>po4a.conf
 [po4a_paths] po/documentation.pot \$lang:po/documentation.\$lang.po
 [options] opt: " -k 80"
 
-- 
GitLab