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 <osamu@debian.org>
This commit is contained in:
Osamu Aoki 2024-01-26 13:08:10 +09:00
parent 599f0486e0
commit 5dd8137e4a
6 changed files with 28 additions and 18 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 <osamu@debian.org>""
[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 \

View file

@ -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 <osamu@debian.org>""
[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 \