Remove intltool dependency

Since gettext 0.19, gettext itself has been able to extract strings from
and merge translations to .desktop files. As a result, there is no need
to use intltool.  More details are available on
https://wiki.gnome.org/MigratingFromIntltoolToGettext, though that page
assumes a project using Autotools, which this project does not.

One advantage of using xgettext rather than intltool is that there is no
need to prefix translatable keys in the .desktop.in file with _. This
patch adjusts tuxpaint.desktop.in accordingly, which makes the input
file itself a valid desktop file.

The LINGUAS file contains the list of supported languages. This could
in principle be generated automatically from one of the other places in
the source tree that has a manually-maintained list of languages; but in
my experience it is generally maintained by hand and checked into the
source tree.

POTFILES.in.in must be updated to remove the intltool-specific file
encoding annotation; instead this is passed to xgettext.

Finally, update-po.sh is rewritten to invoke xgettext and msgfmt rather
than intltool commands.

The mangling of POTFILES.in.in to prefix all filenames with '../' is
only necessary to minimize the churn when updating the .pot and .po
files, to simplify review of this change. The alternative is to pass
--directory=.. to xgettext. This would cause all .po files to be updated
as follows when regenerated:

     #. Response to Black (0, 0, 0) color selected
    -#: ../colors.h:86
    +#: colors.h:86
     msgid "Black!"
     msgstr "Noir !"
This commit is contained in:
Will Thompson 2022-06-10 10:36:50 +01:00
parent e7ec1efdc8
commit 3141249969
5 changed files with 148 additions and 17 deletions

View file

@ -1,6 +0,0 @@
# fake file, so that intltools work
# $Id$
AM_INIT_AUTOMAKE(tuxpaint, 0.9.14)
AM_PROG_XML_I18N_TOOLS

129
src/po/LINGUAS Normal file
View file

@ -0,0 +1,129 @@
ach
af
ak
am
an
ar
as
ast
az
be
bg
bm
bn
bo
br
brx
bs
ca
ca@valencia
cgg
cs
cy
da
de
doi
el
en_AU
en_CA
en_GB
en_ZA
eo
es_MX
es
et
eu
fa
ff
fi
fo
fr
ga
gd
gl
gos
gu
he
hi
hr
hu
hy
id
is
it
iu
ja
kab
ka
km
kn
kok
kok@roman
ko
ks@devanagari
ks
ku
lb
lg
lt
lv
mai
mk
ml
mni@meiteimayek
mni
mn
mr
ms
nb
ne
nl
nn
nr
nso
oc
oj
or
pa
pl
pt_BR
pt
ro
ru
rw
sa
sat@olchiki
sat
sc
sd@devanagari
sd
shs
si
sk
sl
son
sq
sr@latin
sr
su
sv
sw
ta
te
th
tlh
tl
tr
tw
uk
ur
vec
ve
vi
wa
wo
xh
zam
zh_CN
zh_TW
zu

View file

@ -1,4 +1,3 @@
[encoding: UTF-8]
colors.h
dirwalk.c
fill_tools.h

View file

@ -1,14 +1,23 @@
#!/bin/sh
cd $(dirname "$0")
cp POTFILES.in.in POTFILES.in
ls ../../magic/src/*.c | cut -b 4- >> POTFILES.in
sed -e 's/^/..\//' POTFILES.in.in > POTFILES.in
ls ../../magic/src/*.c >> POTFILES.in
xgettext \
--package-name=tuxpaint \
--files-from=POTFILES.in \
--from-code=UTF-8 \
--keyword=gettext_noop \
--add-comments \
--output=tuxpaint.pot
intltool-update --pot
msguniq tuxpaint.pot > temp.tmp && mv -f temp.tmp tuxpaint.pot
for i in *.po ; do
echo $i
msgmerge --update --previous --backup=none $i tuxpaint.pot
done
cd ..
intltool-merge -d -u po tuxpaint.desktop.in tuxpaint.desktop
cd po
msgfmt --desktop \
-d . \
--template ../tuxpaint.desktop.in \
--output-file ../tuxpaint.desktop

View file

@ -1,9 +1,9 @@
[Desktop Entry]
_Name=Tux Paint
Name=Tux Paint
Type=Application
Exec=tuxpaint
Icon=tuxpaint
Terminal=false
Categories=Education;Art;
_GenericName=Drawing program
_Comment=A drawing program for children.
GenericName=Drawing program
Comment=A drawing program for children.