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.

-- 
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	2009-11-15 12:41:25 +0000
+++ Makefile.in	2009-11-15 23:01:10 +0000
@@ -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'
--- po/POTFILES	1970-01-01 00:00:00 +0000
+++ po/POTFILES	2009-11-15 23:00:07 +0000
@@ -0,0 +1,2 @@
+# List of files which contain translatable strings.
+util/i386/pc/grub-mkimage.c

=== added file 'po/ca.po'
--- po/ca.po	1970-01-01 00:00:00 +0000
+++ po/ca.po	2009-11-15 23:05:55 +0000
@@ -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 <rmh.g...@aybabtu.com>, 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 <rmh.g...@aybabtu.com>\n"
+"Language-Team: LANGUAGE <l...@li.org>\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'
--- util/i386/pc/grub-mkimage.c	2009-09-24 13:40:40 +0000
+++ util/i386/pc/grub-mkimage.c	2009-11-15 22:59:36 +0000
@@ -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);

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to