From 5dd8137e4ac91ff945529ab58b6ac6ebfa0fc59a Mon Sep 17 00:00:00 2001 From: Osamu Aoki Date: Fri, 26 Jan 2024 13:08:10 +0900 Subject: [PATCH] refactor po build Drop linenumber for easier merge and diff tracking This is preparation for 3-way clean merge. One example of such 3-way merge article is at: * https://stackoverflow.com/a/29535676/334451 This install some driver like: ``` $ git config merge.merge-po-files.driver "./bin/merge-po-files %A %O %B %P" ``` Note that you also need file `.gitattributes` with following lines: ``` [attr]POFILE merge=merge-po-files locale/*.po POFILE ``` There are other references: * https://github.com/mezis/git-whistles/blob/master/libexec/git-merge-po.sh * https://stackoverflow.com/questions/16214067/wheres-the-3-way-git-merge-driver-for-po-gettext-files/29535676#29535676 * https://stackoverflow.com/questions/2006351/gettext-po-files-under-version-control/11291001#11291001 * https://gist.github.com/SebCorbin/d196a96b1b5f30f3c3947c3d35fe420b Signed-off-by: Osamu Aoki --- Makefile | 15 +++++++-------- bin/{buildxml1 => po4a1} | 5 ++--- bin/{buildxml2 => po4a2} | 6 +++--- bin/{fuzzypo => pofuzzy} | 0 po4a-tmp.cfg.in | 10 ++++++++-- po4a.cfg.in | 10 ++++++++-- 6 files changed, 28 insertions(+), 18 deletions(-) rename bin/{buildxml1 => po4a1} (85%) rename bin/{buildxml2 => po4a2} (94%) rename bin/{fuzzypo => pofuzzy} (100%) diff --git a/Makefile b/Makefile index 2e459554..2b1c29f2 100644 --- a/Makefile +++ b/Makefile @@ -88,7 +88,6 @@ export PERL_HASH_SEE XLINT := xmllint --format XPNO := xsltproc --novalid --nonet XPINC := /usr/bin/faketime @$(SOURCE_DATE_EPOCH) xsltproc --novalid --nonet --xinclude -GETTEXT := po4a-gettextize -M utf-8 -L utf-8 --format docbook MSGATTR := msgattrib MSGCAT := msgcat MSGUNIQ := msguniq --use-first @@ -105,9 +104,9 @@ SRC_PO := $(addsuffix .po, $(addprefix $(DPO)/, $(LANGPO))) SEDF ?= $(DBIN)/replace0 # po4a/opencc translation -BUILDXML1 ?= $(DBIN)/buildxml1 -BUILDXML2 ?= $(DBIN)/buildxml2 -FUZZYPO ?= $(DBIN)/fuzzypo +PO4A1 ?= $(DBIN)/po4a1 +PO4A2 ?= $(DBIN)/po4a2 +POFUZZY ?= $(DBIN)/pofuzzy # Remote file source (related to Debian package archive URLs) #DEBM := http://ftp.us.debian.org/debian/dists @@ -445,7 +444,7 @@ $(MANUAL).en.xmlt: $(DRAW)/$(MANUAL).rawxml $(DRAW)/header.rawxml ####################################################################### # Phase 3 build : English XML -> POT/PO/XML non-ENGLISH ####################################################################### -# This phase of build now calls po4a twice via $(BUILDXML) +# This phase of build now calls po4a twice via $(PO4A1) and $(PO4A2) # base XML files for all languages and update PO # Completion marker is fuzzy.log listng translation status @@ -454,12 +453,12 @@ POFILES = $(addsuffix .po, $(addprefix po/, $(LANGPO))) fuzzy.log: $(POFILES) $(MANUAL).en.xml $(MANUAL).en.xmlt @$(call check-command, po4a) @$(call check-command, msgcat, gettext) - $(BUILDXML1) $(LANGPO) - $(FUZZYPO) $(LANGPO) >fuzzy.log + $(PO4A1) $(LANGPO) + $(POFUZZY) $(LANGPO) >fuzzy.log .PHONY: xml xml: fuzzy.log - $(BUILDXML2) $(LANGPO) + $(PO4A2) $(LANGPO) .PHONY: po po: fuzzy.log diff --git a/bin/buildxml1 b/bin/po4a1 similarity index 85% rename from bin/buildxml1 rename to bin/po4a1 index e3d49f88..dce16e10 100755 --- a/bin/buildxml1 +++ b/bin/po4a1 @@ -22,10 +22,9 @@ make debian-reference.en.xmlt # since po/debian-reference.pot is commited to git repo, no need to do this any more. #touch -t 200001010000.00 po/debian-reference.pot # set up po4a.cfg for po -sed -e "s/@LANGPO@/${LANGPO}/" po4a.cfg.in > po4a.cfg -sed -i "s/@DVERSION@/${DVERSION}/" po4a.cfg +sed -e "s/@LANGPO@/${LANGPO}/" -e "s/@DVERSION@/${DVERSION}/" po4a.cfg.in > po4a.cfg echo "I: update po/*.po based on debian-reference.en.xmlt" -po4a --msgmerge-opt --verbose -v --no-translations po4a.cfg +po4a po4a.cfg diff --git a/bin/buildxml2 b/bin/po4a2 similarity index 94% rename from bin/buildxml2 rename to bin/po4a2 index c600bbed..61bd9121 100755 --- a/bin/buildxml2 +++ b/bin/po4a2 @@ -50,12 +50,12 @@ if echo ${LANGPO} | grep -q zh ; then gen_po_zh_TW fi # set up po4a-tmp.cfg for po-tmp -sed -e "s/@LANGPO@/${LANGPO}/" po4a-tmp.cfg.in > po4a-tmp.cfg -sed -i "s/@DVERSION@/${DVERSION}/" po4a-tmp.cfg +sed -e "s/@LANGPO@/${LANGPO}/" -e "s/@DVERSION@/${DVERSION}/" po4a-tmp.cfg.in \ + > po4a-tmp.cfg echo "I: create empty pot in po-tmp/ with sure-to-be-older timestamp" touch -t 200001010000.00 po-tmp/debian-reference.pot echo "I: update po-tmp/*.po data and build all translations based on debian-reference.en.xml" -po4a -v po4a-tmp.cfg +po4a po4a-tmp.cfg #rm -rf po-tmp diff --git a/bin/fuzzypo b/bin/pofuzzy similarity index 100% rename from bin/fuzzypo rename to bin/pofuzzy diff --git a/po4a-tmp.cfg.in b/po4a-tmp.cfg.in index 9d7b1f32..54933104 100644 --- a/po4a-tmp.cfg.in +++ b/po4a-tmp.cfg.in @@ -3,10 +3,16 @@ [po4a_langs] @LANGPO@ [po4a_paths] po-tmp/debian-reference.pot $lang:po-tmp/$lang.po -[options] opt:"-k 0 -M UTF-8 -L UTF-8" -[options] opt:"--package-name "Debian Reference v2"" +[options] opt:"--keep 0" +[options] opt:"--master-charset UTF-8" +[options] opt:"--localized-charset UTF-8" +[options] opt:"--verbose" +[options] opt:"--translations" +[options] opt:"--porefs file" [options] opt:"--copyright-holder "Copyright (C) 2009-2024 Osamu Aoki "" +[options] opt:"--package-name "Debian Reference"" [options] opt:"--package-version @DVERSION@" +[options] opt:"--msgmerge-opt --verbose" [type: docbook] debian-reference.en.xml \ $lang:debian-reference.$lang.xml \ diff --git a/po4a.cfg.in b/po4a.cfg.in index 7e92a708..c9009931 100644 --- a/po4a.cfg.in +++ b/po4a.cfg.in @@ -3,10 +3,16 @@ [po4a_langs] @LANGPO@ [po4a_paths] po/debian-reference.pot $lang:po/$lang.po -[options] opt:"-k 0 -M UTF-8 -L UTF-8" -[options] opt:"--package-name "Debian Reference"" +[options] opt:"--keep 0" +[options] opt:"--master-charset UTF-8" +[options] opt:"--localized-charset UTF-8" +[options] opt:"--verbose" +[options] opt:"--no-translations" +[options] opt:"--porefs file" [options] opt:"--copyright-holder "Copyright (C) 2009-2024 Osamu Aoki "" +[options] opt:"--package-name "Debian Reference"" [options] opt:"--package-version @DVERSION@" +[options] opt:"--msgmerge-opt --verbose" [type: docbook] debian-reference.en.xmlt \ $lang:debian-reference.$lang.xmlt \