]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
i18n: Build infrastructure
authorAidan Van Dyk <aidan@ifax.com>
Thu, 28 Feb 2008 20:55:09 +0000 (20:55 +0000)
committerAidan Van Dyk <aidan@ifax.com>
Thu, 28 Feb 2008 20:55:09 +0000 (20:55 +0000)
This allows us to "build" .po and .pot files for HylaFAX.

It builds 3 sets:
        libhylafax              Strings used in libhylafax
        hylafax-client          Strings used in hylafax client components
        hylafax-server          Strings used in hylafax server components

All are merged to one master "hylafax.pot" for translating.  The 3
separate catalogs translations are merged out of the master
hylafax.pot/$LANG.po to build the .mo for installation.

Makefile hackery makes me which we only supported "real" makes...

.cvsignore
Makefile.in
configure
defs.in
libhylafax/Makefile.in
nls-rules.mk [new file with mode: 0644]
po/Makefile.in [new file with mode: 0644]
po/nls.mk [new file with mode: 0644]
po/version.po.in [new file with mode: 0644]
rules.in
util/Makefile.in

index bbbad4b584252fa457caf137ad281d24e2ce5213..c480d8456b5f7bcca6e41ce8d0b6669feee01761 100644 (file)
@@ -9,3 +9,4 @@ port.h
 rules
 .project
 .settings
+messages.po
index 343abd0cdf86577b6d537019ea0b663c7668b095..7337a40bf59a4412393fac1ac42dfbfb85326aa1 100644 (file)
@@ -43,7 +43,9 @@ DEPTH = .
 
 SRCDIR = ${TOPSRCDIR}/${DEPTH}
 
-DIRS=  libhylafax \
+DSODIRS        = libhylafax
+
+SRCDIRS = ${DSODIRS} \
        util \
        faxalter \
        faxcover \
@@ -53,14 +55,13 @@ DIRS=       libhylafax \
        faxstat \
        hfaxd \
        sendfax \
-       sendpage \
-       \
+       sendpage
+
+DIRS=  ${SRCDIRS} \
        config \
        etc \
        man
 
-DSODIRS        = libhylafax
-
 TARGETS=hylafax
 
 default all ${TARGETS}:
@@ -102,6 +103,11 @@ dirs::
        else \
            true; \
        fi
+       @if [ "@NLS@" = yes ]; then \
+           ${ECHO} "= "po; cd po; ${MAKE}  ||  exit $?; \
+       else \
+           true; \
+       fi
        @${ECHO} "= "pkg; cd pkg; ${MAKE}  ||  exit $?
 depend::
        @if [ "@PORT@" = yes ]; then \
@@ -213,6 +219,15 @@ distclean: clobber
        (cd pkg; ${MAKE} distclean)
        -${RM} -f defs rules Makefile
 
+update-po::
+       @if [ "@NLS@" != yes ]; then \
+               echo "NLS Not enabled"; false; \
+       fi
+       @for i in ${SRCDIRS}; do \
+           (${ECHO} "= "$$i; cd $$i; ${MAKE} messages.po); \
+       done
+       (cd po; ${MAKE} hylafax.pot)
+
 makeClientDirs::
        -${INSTALL} -u ${SYSUSER} -g ${SYSGROUP} -m ${DIRMODE} \
            -idb hylafax.sw.client -dir \
@@ -273,6 +288,11 @@ install: makeDirs makeDevices
        else \
            true; \
        fi
+       @if [ "@NLS@" = yes ]; then \
+           ${ECHO} "= po"; cd po; ${MAKE} install  ||  exit 1; \
+       else \
+           true; \
+       fi
 
 CLIENTDIRS=\
        faxalter \
@@ -302,6 +322,11 @@ installClient: makeClientDirs
        else \
            true; \
        fi
+       @if [ "@NLS@" = yes ]; then \
+           (${ECHO} "= po"; cd po; ${MAKE} installClient  ||  exit 1; \
+       else \
+           true; \
+       fi
 
 package::
        @${ECHO} "= "pkg; cd pkg; ${MAKE} package
index 58e10b7329a98122d123c79b5234d82ca12845b8..691b5363ea2110e23439a944d56b8c02630121ac 100755 (executable)
--- a/configure
+++ b/configure
@@ -71,6 +71,7 @@ DPS=no
 GS=no
 IMP=no
 UTMP=auto
+NLS=auto
 OPTIMIZER="-O"
 LIBTIFF="-L/usr/local/lib -ltiff"
 TIFFINC=/usr/local/include
@@ -174,7 +175,7 @@ LIBDB
 LLDOPTS
 LN
 LN_S
-LOCALEDIR      DIR_LOCALE
+LOCALEDIR       DIR_LOCALE
 LOCALE_DOMAIN
 HAVE_PAM
 PAMLIBS
@@ -209,6 +210,7 @@ MKDIR
 MKFIFO
 MV
 MV_F
+NLS
 NOCLOBBER_OFF
 NOCLOBBER_ON
 OPTIMIZER
@@ -1657,6 +1659,7 @@ if [ "$CHECK_NLS" != "no" ]; then
        CheckForIncludeFile locale.h && 
            CheckForIncludeFile libintl.h && {
                ENABLE_NLS="#define ENABLE_NLS 1"
+                NLS='yes'
                CheckForLibraryWithArgs gettext '""' -lc || {
                    CheckForLibraryWithArgs gettext '""' -lintl && {
                        Note "Looks like -lintl is needed for gettext support."
@@ -4766,7 +4769,7 @@ SedConfigFiles()
            $MKDIR $dir
        fi
        suffix=`echo $F | $SED 's/.*\.//'`
-       if [ "$suffix" = h ]; then
+       if [ "$suffix" = h ] || [ "$suffix" = po ]; then
            #
            # Compare old and new versions so that include files
            # are only updated when something has changed--this
@@ -4859,6 +4862,9 @@ CONF_FILES="
     sendfax/Makefile
     sendpage/Makefile
     util/Makefile
+    po/Makefile
+
+    po/version.po
 
     port/install.sh
 
@@ -4910,6 +4916,7 @@ test $SGI2FAX = yes &&               SedConfigFiles sgi2fax/Makefile
 test $PORT = yes &&               SedConfigFiles port/Makefile
 test $REGEX = yes &&              SedConfigFiles regex/Makefile
 test $DBLIB = yes &&              SedConfigFiles dblib/Makefile
+test $NLS = yes &&                SedConfigFiles po/Makefile
 test -f $SRCDIR/MLA/VERSION &&    SedConfigFiles MLA/Makefile
 
 if [ "$MAKEDEPINCLUDE" != "sinclude" ]; then
@@ -4941,6 +4948,7 @@ if [ "$MAKEDEPINCLUDE" != "sinclude" ]; then
     test $PORT = yes   && DEPEND="$DEPEND port"
     test $REGEX = yes  && DEPEND="$DEPEND regex"
     test $DBLIB = yes  && DEPEND="$DEPEND dblib"
+    test $NLS = yes    && DEPEND="$DEPEND po"
     test -f $SRCDIR/MLA/VERSION && DEPEND="$DEPEND MLA"
     test -d $SRCDIR/faxview && test -d faxview && DEPEND="$DEPEND faxview"
     for i in $DEPEND; do
diff --git a/defs.in b/defs.in
index 05691a106640ec55013c61edb49a3267b13e5738..96dacd6da679680f89e2f168aa03a80c89a23380 100644 (file)
--- a/defs.in
+++ b/defs.in
@@ -355,3 +355,16 @@ MANCAPPNAME        = @MANCAPPNAME@
 MANCFILENAME   = @MANCFILENAME@
 MANSAPPNAME    = @MANSAPPNAME@
 MANSFILENAME   = @MANSFILENAME@
+#
+# NLS Support
+#
+# All translations listed here must have a translated po/${LANG}.po file
+#
+LOCALEDIR       = @LOCALEDIR@
+
+LANGUAGES       =
+
+XGETTEXT       = xgettext --foreign-user -ctranslator --no-wrap --sort-by-file --omit-header --strict --indent --force-po
+MSGMERGE       = msgmerge --no-wrap --sort-by-file --no-wrap
+MSGFMT         = msgfmt
+MSGCAT         = msgcat
index 1c5ca1e155d115f1651c062cf395de43fe8c0bb9..82191c1e3ab87a65eba197125410a62887d6563e 100644 (file)
@@ -60,6 +60,8 @@ CFILES= cvtfacility.c fxassert.c
 
 TARGETS=libhylafax-${ABI_VERSION}.${DSO}
 
+GETTEXT_TRIGGERS = TEXT
+
 default all::
        @${MAKE} incdepend
        @${MAKE} targets
diff --git a/nls-rules.mk b/nls-rules.mk
new file mode 100644 (file)
index 0000000..911a28a
--- /dev/null
@@ -0,0 +1,20 @@
+# Common rules for Native Language Support (NLS)
+# #
+# # If some subdirectory of the source tree wants to provide NLS, it
+# # needs to define the following make variable assignments:
+# #
+# # SOURCES               -- list of source files that contain message strings
+# # GETTEXT_TRIGGERS      -- (optional) list of functions that contain
+# #                          translatable strings
+# #
+# # That's all.  This will allow a "message.po" to be build there, and
+# # the infrastructue in po/Makefile will use this to update everything
+
+nls-SHOUT:
+       @echo "NLS Settings:"
+       @echo "PO: '${PO_FILES}'"
+       @echo "MO: '${MO_FILES}'"
+       @echo "FILES: ${SOURCES}"
+
+messages.po: ${SOURCES}
+       ${XGETTEXT} -D ${SRCDIR} -n ${addprefix -k, _ ${GETTEXT_TRIGGERS}} ${SOURCES}
diff --git a/po/Makefile.in b/po/Makefile.in
new file mode 100644 (file)
index 0000000..7a0450b
--- /dev/null
@@ -0,0 +1,34 @@
+
+#
+# VERSION:     @VERSION@
+# DATE:                @DATE@
+# TARGET:      @TARGET@
+# CCOMPILER:   @CCOMPILER@
+# CXXCOMPILER: @CXXCOMPILER@
+#
+DEPTH=..
+@MAKEINCLUDE@ @MAKELQUOTE@${DEPTH}/defs@MAKERQUOTE@
+
+LIBVERSION     = @VERSION@
+SRCDIR = ${DEPTH}/${TOPSRCDIR}/po
+VPATH  = ../@SRCDIR@/po
+
+TARGETS=all-mo
+
+default all::
+       @${MAKE} targets
+
+targets: $(TARGETS)
+
+@MAKEINCLUDE@ @MAKELQUOTE@${COMMONRULES}@MAKERQUOTE@
+
+
+CLIENTS        = faxalter faxrm faxstat sendfax sendpage
+
+SERVERS = util
+installClient:
+
+install:
+
+
+@MAKEINCLUDE@ @MAKELQUOTE@${SRCDIR}/nls.mk@MAKERQUOTE@
diff --git a/po/nls.mk b/po/nls.mk
new file mode 100644 (file)
index 0000000..bfc140d
--- /dev/null
+++ b/po/nls.mk
@@ -0,0 +1,55 @@
+#
+# We build the language .po/.mo files with all makes
+#
+# Unfortunately, only real makes (i.e. GNU make) no khow to rebuild
+# the raw .po files properly, but that's not a big problem
+hylafax.pot: version.po libhylafax/messages.pot hylafax-client/messages.pot hylafax-server/messages.pot
+       cat version.po > $@.tmp
+       ${MSGCAT} libhylafax/messages.pot hylafax-client/messages.pot hylafax-server/messages.pot >> $@.tmp
+       mv $@.tmp $@
+
+
+# A bit more trikery here
+# We want $(wildcard...) because we don't want to try to "rebuild" thes messages.pot
+# unless the components exist.  If update-po was run, they should all exist
+# But legacy makes (SCO) don't support $(wildcard...).  Luckly, they don't support $(...)
+# At all, so they just drop it all.  Real makes support $(wildcard)
+# That's why we use the $(...${...})
+libhylafax/messages.pot: $(wildcard ${patsubst %, ${DEPTH}/%/messages.po, libhylafax})
+       test -d libhylafax || mkdir libhylafax
+       ${MSGCAT} $^ > $@.tmp
+       mv $@.tmp $@
+
+hylafax-client/messages.pot: $(wildcard ${patsubst %, ${DEPTH}/%/messages.po, ${CLIENTS}})
+       test -d hylafax-client || mkdir hylafax-client
+       ${MSGCAT} $^ > $@.tmp
+       mv $@.tmp $@
+
+
+hylafax-server/messages.pot: $(wildcard ${patsubst %, ${DEPTH}/%/messages.po, ${SERVERS}})
+       test -d hylafax-server || mkdir hylafax-server
+       ${MSGCAT} $^ > $@.tmp
+       mv $@.tmp $@
+
+# We can't use any normal Make pattern rules while we're stuck supporting
+# legacy comiples like SCO, so be carefull!
+# Here again (like MANCVT) we can't use $<, because we're not an "inferred" rule
+# So techincally, this rule's depencies aren't *quite* complete, but on well
+${CATALOG}/${LANGUAGE}.po: ${CATALOG}/messages.pot
+       test -d ${CATALOG} || mkdir ${CATALOG}
+       touch $@.tmp
+       ${MSGMERGE} $@.tmp $? -o $@ --compendium=${SRCDIR}/${LANGUAGE}.po
+       rm -f $@.tmp
+
+${CATALOG}/${LANGUAGE}.mo: ${CATALOG}/${LANGUAGE}.po
+       ${MSGFMT} -o $@ $?
+
+lang-mo: ${CATALOG}/${LANGUAGE}.mo
+
+#and since we don't have pattern rules, we do this horrid loop
+all-mo:
+       @for l in ${LANGUAGES}; do                                      \
+           for c in libhylafax hylafax-client hylafax-server; do       \
+               ${MAKE} LANGUAGE=$$l CATALOG=$$c lang-mo || exit $?;    \
+           done;                                                       \
+       done
diff --git a/po/version.po.in b/po/version.po.in
new file mode 100644 (file)
index 0000000..d362573
--- /dev/null
@@ -0,0 +1,10 @@
+# HylaFAX PO TEMPLATE
+# This file is distrubuted under the same license as the HylaFAX package.
+#, fuzy
+msgid ""
+msgstr ""
+"Project-Id-Version: HylaFAX @VERSION@\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"PO-Revision-Date: @DATE@\n"
index 05233465d748288c59aa6afab7025d49eb3c9cc2..05b502300492cd0e0f3b818da9c6c4576c1f848e 100644 (file)
--- a/rules.in
+++ b/rules.in
@@ -191,6 +191,9 @@ _cincdepend: .cincdepend
 #
 RAWDEPFILTER= sed -e 's:^:${VPATH}/:'
 
+#include NLS stuff
+@MAKEINCLUDE@ @MAKELQUOTE@${DEPTH}/${TOPSRCDIR}/nls-rules.mk@MAKERQUOTE@
+
 #
 # Include the make dependency file if it exists.
 #
index 5273bb62dff23f80148f8345471a25d8078ffb35..c13e338e0f48cbbf2edf6429dce71be794a899e8 100644 (file)
@@ -53,6 +53,22 @@ default all::
 
 targets: $(TARGETS)
 
+CFILES = faxadduser.c \
+         faxconfig.c \
+         faxdeluser.c \
+         faxmodem.c \
+         faxmsg.c \
+         faxstate.c
+
+C++FILES=checkat.c++ \
+         dialtest.c++ \
+         faxfetch.c++ \
+         faxinfo.c++ \
+         faxwatch.c++ \
+         textfmt.c++ \
+         tiffcheck.c++ \
+         typetest.c++
+
 @MAKEINCLUDE@ @MAKELQUOTE@${COMMONRULES}@MAKERQUOTE@
 
 faxmsg: ${SRCDIR}/faxmsg.c ${LIBS}