]> git.ipfire.org Git - location/libloc.git/commitdiff
Add internationalisation with intltool and gettext
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 1 Feb 2018 14:04:25 +0000 (14:04 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 1 Feb 2018 14:04:25 +0000 (14:04 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
autogen.sh
configure.ac
m4/.gitignore
po/.gitignore [new file with mode: 0644]
po/LINGUAS [new file with mode: 0644]
po/POTFILES.in [new file with mode: 0644]
src/python/location-query.in

index 161f5d38458020abbdfb25966674ca1f53add68c..fc6f3135bb82f56ca69874a76bb123db5c57b94e 100644 (file)
@@ -3,6 +3,8 @@ CLEANFILES =
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 AM_MAKEFLAGS = --no-print-directory
 
+SUBDIRS = . po
+
 AM_CPPFLAGS = \
        -include $(top_builddir)/config.h \
        -DSYSCONFDIR=\""$(sysconfdir)"\" \
@@ -36,6 +38,12 @@ pkgconfigdir = $(libdir)/pkgconfig
 %: %.in Makefile
        $(SED_PROCESS)
 
+@INTLTOOL_POLICY_RULE@
+
+.PHONY: update-po
+update-po:
+       $(MAKE) -C po update-po
+
 EXTRA_DIST += \
        examples/python/create-database.py \
        examples/python/read-database.py
index 16c0eb380d3020876735ada6005671af49453123..ba2845a55d28f852976f8f7ae45f48264dfad261 100755 (executable)
@@ -8,6 +8,7 @@ if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then
         echo "Activated pre-commit hook."
 fi
 
+intltoolize --force --automake
 autoreconf --install --symlink
 
 libdir() {
index 3bd88a2000c3df9237ee09099b48b227de8195dd..567c6113abe534efe044fffd7f86e82501f2bf6a 100644 (file)
@@ -29,6 +29,10 @@ LT_INIT([
 ])
 AC_PREFIX_DEFAULT([/usr])
 
+IT_PROG_INTLTOOL([0.40.0])
+GETTEXT_PACKAGE=${PACKAGE_TARNAME}
+AC_SUBST(GETTEXT_PACKAGE)
+
 AC_PROG_SED
 AC_PROG_MKDIR_P
 
@@ -82,6 +86,7 @@ PKG_CHECK_MODULES([PYTHON], [python-${PYTHON_VERSION}])
 AC_CONFIG_HEADERS(config.h)
 AC_CONFIG_FILES([
         Makefile
+        po/Makefile.in
 ])
 
 AC_OUTPUT
index 38066ddf7cadabe6ee4140de6bd3c539cf2716b5..55eaa803a1b3a698c8703828dc8ddc6545d360c0 100644 (file)
@@ -1,3 +1,4 @@
+intltool.m4
 libtool.m4
 ltoptions.m4
 ltsugar.m4
diff --git a/po/.gitignore b/po/.gitignore
new file mode 100644 (file)
index 0000000..bf46c1e
--- /dev/null
@@ -0,0 +1,6 @@
+/POTFILES
+/Makefile.in.in
+/.intltool-merge-cache
+/Makefile
+/stamp-it
+*.pot
diff --git a/po/LINGUAS b/po/LINGUAS
new file mode 100644 (file)
index 0000000..323d4df
--- /dev/null
@@ -0,0 +1 @@
+# nothing, yet
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644 (file)
index 0000000..9d7af9f
--- /dev/null
@@ -0,0 +1 @@
+src/python/location-query.in
index e750ea4bb15cacfe36b3aa9498c6ea3825aefcbe..b5c1008c816b952e13b4d9b0e1799f868de93a1e 100644 (file)
@@ -18,6 +18,7 @@
 ###############################################################################
 
 import argparse
+import gettext
 import sys
 import syslog
 
@@ -25,7 +26,11 @@ import syslog
 import location
 
 # i18n
-_ = lambda x: x
+def _(singular, plural=None, n=None):
+       if plural:
+               return gettext.dngettext("libloc", singular, plural, n)
+
+       return gettext.dgettext("libloc", singular)
 
 class CLI(object):
        def __init__(self):