gettext in build system
I wrote initial support for gettext in build system. It is available in:
sftp://bzr.savannah.gnu.org/srv/bzr/grub/people/robertmh/gettext/
also attached. It probably still needs some polish, please comment.
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
=== modified file 'Makefile.in'
Makefile.in +21 -2
@@ -41,6 +41,8 @@ includedir = @includedir@ pkgdatadir = $(datadir)/`echo @PACKAGE_TARNAME@ | sed '$(transform)'` pkglibdir = $(libdir)/`echo @PACKAGE_TARNAME@/$(target_cpu)-$(platform) | sed '$(transform)'` +LINGUAS = ca + PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@
@@ -153,7 +155,7 @@ include $(srcdir)/conf/$(target_cpu)-$(p ### General targets. -CLEANFILES += $(pkglib_DATA) $(pkgdata_DATA) +CLEANFILES += $(pkglib_DATA) $(pkgdata_DATA) po/*.mo pkglib_DATA += moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst moddep.lst: $(DEFSYMFILES) $(UNDSYMFILES) genmoddep.awk cat $(DEFSYMFILES) /dev/null \
@@ -237,7 +239,7 @@ build_env.mk: Makefile ) > $@ pkglib_BUILDDIR += config.h grub_script.tab.h -all-local: $(PROGRAMS) $(PKGLIB) $(PKGDATA) $(SCRIPTS) $(INFOS) $(MKFILES) +all-local: $(PROGRAMS) $(PKGLIB) $(PKGDATA) $(SCRIPTS) $(INFOS) $(MKFILES) $(foreach lang, $(LINGUAS), po/$(lang).mo) install: install-local
@@ -301,6 +303,13 @@ install-local: all dest="`echo $$file | sed 's,.*/,,'`"; \ $(INSTALL_DATA) $$dir$$file $(DESTDIR)$(libdir)/grub/$$dest; \ done + $(foreach lang, $(LINGUAS), \ + $(SHELL) $(mkinstalldirs) $(DESTDIR)/$(datadir)/locale/$(lang)/LC_MESSAGES + @list='po/$(lang).mo'; \ + for file in $$list; do \ + if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \ + $(INSTALL_DATA) $$dir$$file $(DESTDIR)/$(datadir)/locale/$(lang)/LC_MESSAGES/grub.mo; \ + done) $(SHELL) $(mkinstalldirs) $(DESTDIR)$(infodir) @list='$(info_INFOS)'; \ for file in $$list; do \
@@ -455,6 +464,16 @@ gensymlist.sh: gensymlist.sh.in config.s genkernsyms.sh: genkernsyms.sh.in config.status $(SHELL) ./config.status +po/messages.pot: po/POTFILES + xgettext --from-code=utf-8 --keyword=_ -f $< -o $@ + +po/*.po: po/messages.pot + msgmerge -U $@ po/messages.pot + +po/%.mo: po/%.po + $(MKDIR_P) $$(dirname $@) + msgfmt -c --statistics -o $@ $^ + .PHONY: all install install-strip uninstall clean mostlyclean distclean .PHONY: maintainer-clean info dvi dist check
=== added directory 'po'
=== added file 'po/POTFILES'
POTFILES +2 -0
@@ -0,0 +1,2 @@ +# List of files which contain translatable strings. +util/i386/pc/grub-mkimage.c
=== added file 'po/ca.po'
ca.po +20 -0
@@ -0,0 +1,20 @@ +# Copyright (C) 2009 Free Software Foundation, Inc +# This file is distributed under the same license as the GNU GRUB package. +# Robert Millan <[email protected]>, 2009. +# +msgid "" +msgstr "" +"Project-Id-Version: GNU GRUB\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2009-11-16 00:05+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Robert Millan <[email protected]>\n" +"Language-Team: LANGUAGE <[email protected]>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: util/i386/pc/grub-mkimage.c:322 +#, c-format +msgid "Try ``%s --help'' for more information.\n" +msgstr "Proveu «%s --help» per a obtenir més informació.\n"
=== modified file 'util/i386/pc/grub-mkimage.c'
i386/pc/grub-mkimage.c +7 -1
@@ -33,6 +33,10 @@#include <string.h> #include <stdlib.h> +#include <locale.h> +#include <libintl.h> +#define _ (str) gettext(str) +#define _GNU_SOURCE 1#include <getopt.h>
@@ -315,7 +319,7 @@ static void usage (int status) {if (status) -fprintf (stderr,"Try ``grub-mkimage --help'' for more information.\n" ); +fprintf (stderr,_ ("Try ``%s --help'' for more information.\n" ), progname);else printf ("\ Usage: grub-mkimage [OPTION]... [MODULES]\n\
@@ -349,6 +353,8 @@ main (int argc, char *argv[]) progname ="grub-mkimage" ; +textdomain ("grub" ); +while (1 ) {int c =getopt_long (argc, argv,"d:p:m:c:o:hVv" , options,0 );
Makefile.in gensymlist.sh: gensymlist.sh.in config.s · line 475
Quoted 9 lines · Robert Millan
Makefile.in +9
-0+po/messages.pot: po/POTFILES + xgettext --from-code=utf-8 --keyword=_ -f $< -o $@ + +po/*.po: po/messages.pot + msgmerge -U $@ po/messages.pot + +po/%.mo: po/%.po + $(MKDIR_P) $$(dirname $@) + msgfmt -c --statistics -o $@ $^
Obvious missing thing is that these should be autoconffed.
Quoted 1 line
+#define
_(str)gettext(str)
And I'm not sure if this is the right place to define _. Isn't there a system-wide definition?
Quoted 1 line
+ textdomain ("grub");
What's the usual way to handle this? TEXTDOMAIN macro?
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Quoted 5 lines · Robert Millan
Quoted 1 line · Robert Millan
+#define
_(str)gettext(str)And I'm not sure if this is the right place to define _. Isn't there a system-wide definition?
It's traditional to define _ in each project, since it's rather namespace-invasive.
Quoted 3 lines
Quoted 1 line
+ textdomain ("grub");
What's the usual way to handle this? TEXTDOMAIN macro?
I usually use textdomain (PACKAGE).
Signature · 1 line
Colin Watson [[email protected]]
Quoted 5 lines · Colin Watson
Quoted 3 lines
Quoted 1 line
+ textdomain ("grub");
What's the usual way to handle this? TEXTDOMAIN macro?
I usually use textdomain (PACKAGE).
It's a bit unusual that we don't have PACKAGE. This is usually provided by aclocal via AM_INIT_AUTOMAKE(), so I guess it's time to start auto-generating aclocal.m4, as with attached patch.
Comments?
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
2009-11-16 Robert Millan <[email protected]>
* aclocal.m4: Move from here ...
* acinclude.m4: ... to here.
* autogen.sh: Add call to `aclocal'.
* configure.ac: Add AM_INIT_AUTOMAKE() after AC_INIT() call.
=== renamed file 'aclocal.m4' => 'acinclude.m4'
=== modified file 'autogen.sh'
autogen.sh +1 -0
@@ -2,6 +2,7 @@ set -e +aclocal autoconf autoheader echo timestamp > stamp-h.in
=== modified file 'configure.ac'
configure.ac +1 -0
@@ -32,6 +32,7 @@ dnl type. AC_INIT([GRUB],[1.97],[[email protected]]) +AM_INIT_AUTOMAKE() AC_PREREQ(2.59d) AC_CONFIG_SRCDIR([include/grub/dl.h]) AC_CONFIG_HEADER([config.h])
Hi Robert,
Please excuse the total lack of input on this issue, I've been really busy the last few weekends.
Quoted 12 lines · Robert Millan
Makefile.in gensymlist.sh: gensymlist.sh.in config.s · line 475
Quoted 9 lines · Robert Millan
Makefile.in +9
-0+po/messages.pot: po/POTFILES + xgettext --from-code=utf-8 --keyword=_ -f $< -o $@ + +po/*.po: po/messages.pot + msgmerge -U $@ po/messages.pot + +po/%.mo: po/%.po + $(MKDIR_P) $$(dirname $@) + msgfmt -c --statistics -o $@ $^Obvious missing thing is that these should be autoconffed.
Also, as something merely cosmetic, messages.pot could be $(PACKAGE).pot, which is more common.
Quoted 3 lines
Quoted 1 line
+#define
_(str)gettext(str)And I'm not sure if this is the right place to define _. Isn't there a system-wide definition?
This, and others, sometimes go in a common .h to avoid duplication. Many grub utilities are going to add this kind of stuff.
Quoted 2 lines
Quoted 1 line
+ textdomain ("grub");
What's the usual way to handle this? TEXTDOMAIN macro?
As Colin said, $PACKAGE is common.
I haven't tested this patch yet, but I'm not sure if a bindtextdomain() call is needed here too.
The rest looks good, given there's no automake.
Jordi
Signature · 3 lines
Jordi Mallach Pérez -- Debian developer http://www.debian.org/ [email protected] [email protected] http://www.sindominio.net/ GnuPG public key information available at http://oskuro.net/
Quoted 3 lines · Jordi Mallach
Also, as something merely cosmetic, messages.pot could be $(PACKAGE).pot, which is more common.
Changed in my gettext branch.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
+#define
_(str)gettext(str)And I'm not sure if this is the right place to define _. Isn't there a system-wide definition?
This, and others, sometimes go in a common .h to avoid duplication. Many grub utilities are going to add this kind of stuff.
I wonder where would we put this. Is there any convention?
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
+ textdomain ("grub");
What's the usual way to handle this? TEXTDOMAIN macro?
As Colin said, $PACKAGE is common.
I haven't tested this patch yet, but I'm not sure if abindtextdomain()call is needed here too.
This requires LOCALEDIR. Should we add po.m4 in order to get this, or just define it ourselves?
Quoted 1 line
The rest looks good, given there's no automake.
We have aclocal now (in my branch). Is gettext.m4 usable to us?
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Btw, I gettextified util/grub.d/10_linux.in in my gettext branch, but adding it to POTFILES is a bit problematic.
xgettext recognizes languages either by checking the file suffix or via explicit command-line option. However 10_linux.in doesn't end in .sh and --language=Shell in the generic xgettext call would break detection of C files.
Is there a solution that doesn't involve renaming 10_linux.in nor maintaining a separate list of files for Shell language?
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
Quoted 7 lines · Robert Millan
xgettext recognizes languages either by checking the file suffix or via explicit command-line option. However 10_linux.in doesn't end in .sh and --language=Shell in the generic xgettext call would break detection of C files.
Is there a solution that doesn't involve renaming 10_linux.in nor maintaining a separate list of files for Shell language?
We need to look at what tricks intltool uses for this, as GNOME translates desktop files and other "unusual" files using .in files. Can't do that right now though, I need to go to bed RSN.
Jordi
Signature · 3 lines
Jordi Mallach Pérez -- Debian developer http://www.debian.org/ [email protected] [email protected] http://www.sindominio.net/ GnuPG public key information available at http://oskuro.net/
Quoted 6 lines · Robert Millan
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
+#define
_(str)gettext(str)And I'm not sure if this is the right place to define _. Isn't there a system-wide definition?
This, and others, sometimes go in a common .h to avoid duplication. Many grub utilities are going to add this kind of stuff.
I wonder where would we put this. Is there any convention?
I'm not aware of any convention, not even for GNU packages. nls.h, i18n.h, grub-i18n.h. You name it. :)
Quoted 4 lines
Quoted 2 lines
I haven't tested this patch yet, but I'm not sure if a
bindtextdomain()call is needed here too.This requires LOCALEDIR. Should we add po.m4 in order to get this, or just define it ourselves?
*shrug*, I think just assuming the usual $(datadir)/locale is ok. po.m4 does provide checks for the gettext tools iirc, though, so that might be useful in its own right.
Quoted 2 lines
Quoted 1 line
The rest looks good, given there's no automake.
We have aclocal now (in my branch). Is gettext.m4 usable to us?
I think so, if platforms which don't use GNU gettext, or have an incompatible gettext implementation are supported. It provides checks for gettext(), ngettext(), setlocale() and friends, so yep, probably.
Signature · 3 lines
Jordi Mallach Pérez -- Debian developer http://www.debian.org/ [email protected] [email protected] http://www.sindominio.net/ GnuPG public key information available at http://oskuro.net/
Quoted 10 lines · Jordi Mallach
Quoted 6 lines · Robert Millan
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
+#define
_(str)gettext(str)And I'm not sure if this is the right place to define _. Isn't there a system-wide definition?
This, and others, sometimes go in a common .h to avoid duplication. Many grub utilities are going to add this kind of stuff.
I wonder where would we put this. Is there any convention?
I'm not aware of any convention, not even for GNU packages.
nls.h,i18n.h,grub-i18n.h. You name it. :)
Ok. <grub/i18n.h> then.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
I haven't tested this patch yet, but I'm not sure if a
bindtextdomain()call is needed here too.This requires LOCALEDIR. Should we add po.m4 in order to get this, or just define it ourselves?
*shrug*, I think just assuming the usual $(datadir)/locale is ok. po.m4 does provide checks for the gettext tools iirc, though, so that might be useful in its own right.
I enabled AM_GNU_GETTEXT() which drags that in, as well as a few of the other declarations we needed.
Thanks!
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
I think my gettext branch is reasonably complete now. If you can, anyone please review before I merge it in trunk:
sftp://bzr.savannah.gnu.org/srv/bzr/grub/people/robertmh/gettext/
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."