From ed101e8122c3dcb9fe9dcef1183bd74d534e7c72 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Sun, 15 Nov 2009 23:11:01 +0000 Subject: [PATCH 01/15] Initial support for gettext in build system. --- Makefile.in | 23 +++++++++++++++++++++-- po/POTFILES | 2 ++ po/ca.po | 20 ++++++++++++++++++++ util/i386/pc/grub-mkimage.c | 8 +++++++- 4 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 po/POTFILES create mode 100644 po/ca.po diff --git a/Makefile.in b/Makefile.in index 89d5189eb..0b599f51b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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)-$(platform).mk ### 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.status 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 diff --git a/po/POTFILES b/po/POTFILES new file mode 100644 index 000000000..d99ec5449 --- /dev/null +++ b/po/POTFILES @@ -0,0 +1,2 @@ +# List of files which contain translatable strings. +util/i386/pc/grub-mkimage.c diff --git a/po/ca.po b/po/ca.po new file mode 100644 index 000000000..4213346d4 --- /dev/null +++ b/po/ca.po @@ -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 , 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 \n" +"Language-Team: LANGUAGE \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" diff --git a/util/i386/pc/grub-mkimage.c b/util/i386/pc/grub-mkimage.c index 15168f8fa..86f480835 100644 --- a/util/i386/pc/grub-mkimage.c +++ b/util/i386/pc/grub-mkimage.c @@ -33,6 +33,10 @@ #include #include +#include +#include +#define _(str) gettext(str) + #define _GNU_SOURCE 1 #include @@ -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); From fc22844e83fcfe94c074141741146820e2db22bc Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Mon, 16 Nov 2009 19:31:29 +0000 Subject: [PATCH 02/15] 2009-11-16 Robert Millan * 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. --- ChangeLog.gettext | 6 ++++++ aclocal.m4 => acinclude.m4 | 0 autogen.sh | 1 + configure.ac | 1 + 4 files changed, 8 insertions(+) create mode 100644 ChangeLog.gettext rename aclocal.m4 => acinclude.m4 (100%) diff --git a/ChangeLog.gettext b/ChangeLog.gettext new file mode 100644 index 000000000..402d93250 --- /dev/null +++ b/ChangeLog.gettext @@ -0,0 +1,6 @@ +2009-11-16 Robert Millan + + * 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. diff --git a/aclocal.m4 b/acinclude.m4 similarity index 100% rename from aclocal.m4 rename to acinclude.m4 diff --git a/autogen.sh b/autogen.sh index 6751c8adc..8e5a29215 100755 --- a/autogen.sh +++ b/autogen.sh @@ -2,6 +2,7 @@ set -e +aclocal autoconf autoheader echo timestamp > stamp-h.in diff --git a/configure.ac b/configure.ac index 6287c4f59..3178f6c4a 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,7 @@ dnl type. AC_INIT([GRUB],[1.97],[bug-grub@gnu.org]) +AM_INIT_AUTOMAKE() AC_PREREQ(2.59d) AC_CONFIG_SRCDIR([include/grub/dl.h]) AC_CONFIG_HEADER([config.h]) From 49a38e7696fd98dd00d44b5b9a66279f8c80824f Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Mon, 16 Nov 2009 19:36:12 +0000 Subject: [PATCH 03/15] sed Makefile.in -e "s/messages.pot/\$(PACKAGE).pot/g" -i --- Makefile.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.in b/Makefile.in index 0b599f51b..82cc0987a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -464,11 +464,11 @@ gensymlist.sh: gensymlist.sh.in config.status genkernsyms.sh: genkernsyms.sh.in config.status $(SHELL) ./config.status -po/messages.pot: po/POTFILES +po/$(PACKAGE).pot: po/POTFILES xgettext --from-code=utf-8 --keyword=_ -f $< -o $@ -po/*.po: po/messages.pot - msgmerge -U $@ po/messages.pot +po/*.po: po/$(PACKAGE).pot + msgmerge -U $@ po/$(PACKAGE).pot po/%.mo: po/%.po $(MKDIR_P) $$(dirname $@) From f5e9dadb587226cf6035bc5e360414ee9074dc81 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Mon, 16 Nov 2009 20:03:14 +0000 Subject: [PATCH 04/15] Use PACKAGE instead of hardcoding "grub". --- Makefile.in | 4 +++- util/i386/pc/grub-mkimage.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile.in b/Makefile.in index 82cc0987a..6f08d5a6f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -49,6 +49,8 @@ PACKAGE_VERSION = @PACKAGE_VERSION@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE = @PACKAGE@ + host_os = @host_os@ host_kernel = @host_kernel@ host_cpu = @host_cpu@ @@ -308,7 +310,7 @@ install-local: all @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; \ + $(INSTALL_DATA) $$dir$$file $(DESTDIR)/$(datadir)/locale/$(lang)/LC_MESSAGES/$(PACKAGE).mo; \ done) $(SHELL) $(mkinstalldirs) $(DESTDIR)$(infodir) @list='$(info_INFOS)'; \ diff --git a/util/i386/pc/grub-mkimage.c b/util/i386/pc/grub-mkimage.c index 86f480835..94819bdab 100644 --- a/util/i386/pc/grub-mkimage.c +++ b/util/i386/pc/grub-mkimage.c @@ -353,7 +353,7 @@ main (int argc, char *argv[]) progname = "grub-mkimage"; - textdomain ("grub"); + textdomain (PACKAGE); while (1) { From 5f4db17d00b58e80755f25262e7f2b1618016ac7 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Mon, 16 Nov 2009 20:12:53 +0000 Subject: [PATCH 05/15] Add aclocal.m4, po/*.mo and po/grub.pot. --- .bzrignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.bzrignore b/.bzrignore index 91e959171..999e44c95 100644 --- a/.bzrignore +++ b/.bzrignore @@ -2,6 +2,7 @@ 10_* 30_os-prober 40_custom +aclocal.m4 autom4te.cache build_env.mk .bzrignore @@ -48,6 +49,8 @@ Makefile *.mod mod-*.c *.pf2 +po/*.mo +po/grub.pot stamp-h stamp-h1 stamp-h.in From a1085f18c56e3006dd03dc6fe4ca22ac3ec49fdc Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Mon, 16 Nov 2009 20:19:42 +0000 Subject: [PATCH 06/15] Gettextify. --- util/grub.d/10_linux.in | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index f17955846..65daf0da6 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -21,6 +21,9 @@ exec_prefix=@exec_prefix@ libdir=@libdir@ . ${libdir}/grub/grub-mkconfig_lib +. /usr/bin/gettext.sh +export TEXTDOMAIN=@PACKAGE@ + if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then OS=GNU/Linux else @@ -44,15 +47,22 @@ fi linux_entry () { - cat << EOF -menuentry "$1" { -EOF + os="$1" + version="$2" + recovery="$3" + args="$4" + if ${recovery} ; then + title="$(gettext "%s, with Linux %s (recovery mode)")" + else + title="$(gettext "%s, with Linux %s")" + fi + printf "menuentry \"${title}\" {" ${os} ${version} if [ -z "${prepare_boot_cache}" ]; then prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")" fi printf '%s\n' "${prepare_boot_cache}" cat << EOF - linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro $2 + linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} EOF if test -n "${initrd}" ; then cat << EOF @@ -95,10 +105,10 @@ while [ "x$list" != "x" ] ; do linux_root_device_thisversion=${GRUB_DEVICE} fi - linux_entry "${OS}, with Linux ${version}" \ + linux_entry "${OS}" "${version}" false \ "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then - linux_entry "${OS}, with Linux ${version} (recovery mode)" \ + linux_entry "${OS}" "${version}" true \ "single ${GRUB_CMDLINE_LINUX}" fi From 9a90f817a04f722981eef92e00590c8fc29be9d9 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Tue, 17 Nov 2009 09:52:08 +0000 Subject: [PATCH 07/15] Move i18n declarations to their own file. --- include/grub/i18n.h | 30 ++++++++++++++++++++++++++++++ util/i386/pc/grub-mkimage.c | 5 +---- 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 include/grub/i18n.h diff --git a/include/grub/i18n.h b/include/grub/i18n.h new file mode 100644 index 000000000..e436f6e28 --- /dev/null +++ b/include/grub/i18n.h @@ -0,0 +1,30 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2009 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_I18N_H +#define GRUB_I18N_H 1 + +#ifdef GRUB_UTIL +# include +# include +# define _(str) gettext(str) +#else +# define _(str) str +#endif + +#endif /* GRUB_I18N_H */ diff --git a/util/i386/pc/grub-mkimage.c b/util/i386/pc/grub-mkimage.c index 94819bdab..a720892f6 100644 --- a/util/i386/pc/grub-mkimage.c +++ b/util/i386/pc/grub-mkimage.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -33,10 +34,6 @@ #include #include -#include -#include -#define _(str) gettext(str) - #define _GNU_SOURCE 1 #include From ab502ec59dd90ca4c0e06cda2a0b87a71659f620 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Tue, 17 Nov 2009 10:31:08 +0000 Subject: [PATCH 08/15] * conf/common.rmk (grub_mkisofs_CFLAGS): Move `-I$(srcdir)/gnulib' from here ... * Makefile.in (CPPFLAGS): ... to here. --- ChangeLog.gettext | 4 ++++ Makefile.in | 2 +- conf/common.rmk | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog.gettext b/ChangeLog.gettext index 402d93250..966bf8e7d 100644 --- a/ChangeLog.gettext +++ b/ChangeLog.gettext @@ -4,3 +4,7 @@ * acinclude.m4: ... to here. * autogen.sh: Add call to `aclocal'. * configure.ac: Add AM_INIT_AUTOMAKE() after AC_INIT() call. + + * conf/common.rmk (grub_mkisofs_CFLAGS): Move `-I$(srcdir)/gnulib' + from here ... + * Makefile.in (CPPFLAGS): ... to here. diff --git a/Makefile.in b/Makefile.in index 6f08d5a6f..3a4c158c6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -71,7 +71,7 @@ CC = @CC@ CFLAGS = @CFLAGS@ ASFLAGS = @ASFLAGS@ LDFLAGS = @LDFLAGS@ -CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/include -Wall -W \ +CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/gnulib -I$(srcdir)/include -Wall -W \ -DGRUB_LIBDIR=\"$(pkglibdir)\" TARGET_CC = @TARGET_CC@ TARGET_CFLAGS = @TARGET_CFLAGS@ diff --git a/conf/common.rmk b/conf/common.rmk index a66bd97fd..57b47a669 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -38,7 +38,7 @@ grub_mkisofs_SOURCES = util/mkisofs/eltorito.c \ \ gnulib/fnmatch.c gnulib/getopt1.c gnulib/getopt.c grub_mkisofs_CFLAGS = -D_FILE_OFFSET_BITS=64 \ - -I$(srcdir)/util/mkisofs/include -I$(srcdir)/gnulib \ + -I$(srcdir)/util/mkisofs/include \ -Wno-all -Werror # For grub-fstest. From 548643e528745aa150fddea1a677cc67614c547c Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Tue, 17 Nov 2009 10:40:43 +0000 Subject: [PATCH 09/15] * gnulib/progname.c: New file (imported from Gnulib). * gnulib/progname.h: Likewise. * conf/i386-pc.rmk (grub_mkimage_SOURCES): Add `gnulib/progname.c'. * util/i386/pc/grub-mkimage.c: Include `"progname.h"'. (usage): Replace `progname' with `program_name'. (main): Use set_program_name() for program name initialization. --- ChangeLog.gettext | 7 ++++ conf/i386-pc.rmk | 2 +- gnulib/progname.c | 78 +++++++++++++++++++++++++++++++++++++ gnulib/progname.h | 60 ++++++++++++++++++++++++++++ util/i386/pc/grub-mkimage.c | 7 ++-- 5 files changed, 150 insertions(+), 4 deletions(-) create mode 100644 gnulib/progname.c create mode 100644 gnulib/progname.h diff --git a/ChangeLog.gettext b/ChangeLog.gettext index 966bf8e7d..dc59657a3 100644 --- a/ChangeLog.gettext +++ b/ChangeLog.gettext @@ -1,5 +1,12 @@ 2009-11-16 Robert Millan + * gnulib/progname.c: New file (imported from Gnulib). + * gnulib/progname.h: Likewise. + * conf/i386-pc.rmk (grub_mkimage_SOURCES): Add `gnulib/progname.c'. + * util/i386/pc/grub-mkimage.c: Include `"progname.h"'. + (usage): Replace `progname' with `program_name'. + (main): Use set_program_name() for program name initialization. + * aclocal.m4: Move from here ... * acinclude.m4: ... to here. * autogen.sh: Add call to `aclocal'. diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index a3aae6bad..fecd01828 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -87,7 +87,7 @@ sbin_UTILITIES += grub-emu endif # For grub-mkimage. -grub_mkimage_SOURCES = util/i386/pc/grub-mkimage.c util/misc.c \ +grub_mkimage_SOURCES = gnulib/progname.c util/i386/pc/grub-mkimage.c util/misc.c \ util/resolve.c lib/LzmaEnc.c lib/LzFind.c grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR) util/i386/pc/grub-mkimage.c_DEPENDENCIES = Makefile diff --git a/gnulib/progname.c b/gnulib/progname.c new file mode 100644 index 000000000..bfa374a52 --- /dev/null +++ b/gnulib/progname.c @@ -0,0 +1,78 @@ +/* Program name management. + Copyright (C) 2001-2003, 2005-2009 Free Software Foundation, Inc. + Written by Bruno Haible , 2001. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + +#include + +/* Specification. */ +#undef ENABLE_RELOCATABLE /* avoid defining set_program_name as a macro */ +#include "progname.h" + +#include /* get program_invocation_name declaration */ +#include + + +/* String containing name the program is called with. + To be initialized by main(). */ +const char *program_name = NULL; + +/* Set program_name, based on argv[0]. */ +void +set_program_name (const char *argv0) +{ + /* libtool creates a temporary executable whose name is sometimes prefixed + with "lt-" (depends on the platform). It also makes argv[0] absolute. + But the name of the temporary executable is a detail that should not be + visible to the end user and to the test suite. + Remove this "/.libs/" or "/.libs/lt-" prefix here. */ + const char *slash; + const char *base; + + slash = strrchr (argv0, '/'); + base = (slash != NULL ? slash + 1 : argv0); + if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0) + { + argv0 = base; + if (strncmp (base, "lt-", 3) == 0) + { + argv0 = base + 3; + /* On glibc systems, remove the "lt-" prefix from the variable + program_invocation_short_name. */ +#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME + program_invocation_short_name = (char *) argv0; +#endif + } + } + + /* But don't strip off a leading / in general, because when the user + runs + /some/hidden/place/bin/cp foo foo + he should get the error message + /some/hidden/place/bin/cp: `foo' and `foo' are the same file + not + cp: `foo' and `foo' are the same file + */ + + program_name = argv0; + + /* On glibc systems, the error() function comes from libc and uses the + variable program_invocation_name, not program_name. So set this variable + as well. */ +#if HAVE_DECL_PROGRAM_INVOCATION_NAME + program_invocation_name = (char *) argv0; +#endif +} diff --git a/gnulib/progname.h b/gnulib/progname.h new file mode 100644 index 000000000..82615c6bc --- /dev/null +++ b/gnulib/progname.h @@ -0,0 +1,60 @@ +/* Program name management. + Copyright (C) 2001-2004, 2006 Free Software Foundation, Inc. + Written by Bruno Haible , 2001. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef _PROGNAME_H +#define _PROGNAME_H + +/* Programs using this file should do the following in main(): + set_program_name (argv[0]); + */ + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* String containing name the program is called with. */ +extern const char *program_name; + +/* Set program_name, based on argv[0]. */ +extern void set_program_name (const char *argv0); + +#if ENABLE_RELOCATABLE + +/* Set program_name, based on argv[0], and original installation prefix and + directory, for relocatability. */ +extern void set_program_name_and_installdir (const char *argv0, + const char *orig_installprefix, + const char *orig_installdir); +#undef set_program_name +#define set_program_name(ARG0) \ + set_program_name_and_installdir (ARG0, INSTALLPREFIX, INSTALLDIR) + +/* Return the full pathname of the current executable, based on the earlier + call to set_program_name_and_installdir. Return NULL if unknown. */ +extern char *get_full_program_name (void); + +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* _PROGNAME_H */ diff --git a/util/i386/pc/grub-mkimage.c b/util/i386/pc/grub-mkimage.c index a720892f6..249a40976 100644 --- a/util/i386/pc/grub-mkimage.c +++ b/util/i386/pc/grub-mkimage.c @@ -37,6 +37,8 @@ #define _GNU_SOURCE 1 #include +#include "progname.h" + #ifdef ENABLE_LZMA #include @@ -316,7 +318,7 @@ static void usage (int status) { if (status) - fprintf (stderr, _("Try ``%s --help'' for more information.\n"), progname); + fprintf (stderr, _("Try ``%s --help'' for more information.\n"), program_name); else printf ("\ Usage: grub-mkimage [OPTION]... [MODULES]\n\ @@ -348,8 +350,7 @@ main (int argc, char *argv[]) char *config = NULL; FILE *fp = stdout; - progname = "grub-mkimage"; - + set_program_name (argv[0]); textdomain (PACKAGE); while (1) From 1608391625a481388ad1aeced6c68b3148453edb Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Tue, 17 Nov 2009 10:43:26 +0000 Subject: [PATCH 10/15] Reorganize. --- ChangeLog.gettext | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ChangeLog.gettext b/ChangeLog.gettext index dc59657a3..1549302fb 100644 --- a/ChangeLog.gettext +++ b/ChangeLog.gettext @@ -1,4 +1,4 @@ -2009-11-16 Robert Millan +2009-11-17 Robert Millan * gnulib/progname.c: New file (imported from Gnulib). * gnulib/progname.h: Likewise. @@ -7,11 +7,15 @@ (usage): Replace `progname' with `program_name'. (main): Use set_program_name() for program name initialization. - * 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. +2009-11-17 Robert Millan * conf/common.rmk (grub_mkisofs_CFLAGS): Move `-I$(srcdir)/gnulib' from here ... * Makefile.in (CPPFLAGS): ... to here. + +2009-11-16 Robert Millan + + * 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. From 336262f829c2ce2f4e2a4594dca1220b2888d431 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Tue, 17 Nov 2009 10:47:22 +0000 Subject: [PATCH 11/15] 2009-11-17 Robert Millan * configure.ac: Call AM_GNU_GETTEXT() (defines localedir, among other things). * Makefile.in (CPPFLAGS): Add `-DLOCALEDIR=\"$(localedir)\"'. * util/i386/pc/grub-mkimage.c (main): Issue setlocale() and bindtextdomain() calls for gettext initialization. --- ChangeLog.gettext | 8 ++++++++ Makefile.in | 2 +- configure.ac | 1 + util/i386/pc/grub-mkimage.c | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog.gettext b/ChangeLog.gettext index 1549302fb..19e83f0bb 100644 --- a/ChangeLog.gettext +++ b/ChangeLog.gettext @@ -1,3 +1,11 @@ +2009-11-17 Robert Millan + + * configure.ac: Call AM_GNU_GETTEXT() (defines localedir, among + other things). + * Makefile.in (CPPFLAGS): Add `-DLOCALEDIR=\"$(localedir)\"'. + * util/i386/pc/grub-mkimage.c (main): Issue setlocale() and + bindtextdomain() calls for gettext initialization. + 2009-11-17 Robert Millan * gnulib/progname.c: New file (imported from Gnulib). diff --git a/Makefile.in b/Makefile.in index 3a4c158c6..07f0b6fec 100644 --- a/Makefile.in +++ b/Makefile.in @@ -72,7 +72,7 @@ CFLAGS = @CFLAGS@ ASFLAGS = @ASFLAGS@ LDFLAGS = @LDFLAGS@ CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/gnulib -I$(srcdir)/include -Wall -W \ - -DGRUB_LIBDIR=\"$(pkglibdir)\" + -DGRUB_LIBDIR=\"$(pkglibdir)\" -DLOCALEDIR=\"$(localedir)\" TARGET_CC = @TARGET_CC@ TARGET_CFLAGS = @TARGET_CFLAGS@ TARGET_ASFLAGS = @TARGET_ASFLAGS@ diff --git a/configure.ac b/configure.ac index 3178f6c4a..587f2118d 100644 --- a/configure.ac +++ b/configure.ac @@ -33,6 +33,7 @@ dnl type. AC_INIT([GRUB],[1.97],[bug-grub@gnu.org]) AM_INIT_AUTOMAKE() +AM_GNU_GETTEXT() AC_PREREQ(2.59d) AC_CONFIG_SRCDIR([include/grub/dl.h]) AC_CONFIG_HEADER([config.h]) diff --git a/util/i386/pc/grub-mkimage.c b/util/i386/pc/grub-mkimage.c index 249a40976..2001804c3 100644 --- a/util/i386/pc/grub-mkimage.c +++ b/util/i386/pc/grub-mkimage.c @@ -351,6 +351,8 @@ main (int argc, char *argv[]) FILE *fp = stdout; set_program_name (argv[0]); + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); while (1) From 8c37c91f9986655fe99d5e0bedd9deaf593546e3 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Tue, 17 Nov 2009 11:20:39 +0000 Subject: [PATCH 12/15] 2009-11-17 Robert Millan * Makefile.in (XGETTEXT, MSGMERGE, MSGFMT, LINGUAS): New variables. (po/$(PACKAGE).pot): Replace `xgettext' with `$(XGETTEXT)'. (po/*.po): Replace `msgmerge' with `$(MSGMERGE)'. (po/%.mo): Replace `msgfmt' with `$(MSGFMT)'. * po/LINGUAS: New file. --- ChangeLog.gettext | 8 ++++++++ Makefile.in | 12 ++++++++---- po/LINGUAS | 1 + 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 po/LINGUAS diff --git a/ChangeLog.gettext b/ChangeLog.gettext index 19e83f0bb..a1451f1d1 100644 --- a/ChangeLog.gettext +++ b/ChangeLog.gettext @@ -1,3 +1,11 @@ +2009-11-17 Robert Millan + + * Makefile.in (XGETTEXT, MSGMERGE, MSGFMT, LINGUAS): New variables. + (po/$(PACKAGE).pot): Replace `xgettext' with `$(XGETTEXT)'. + (po/*.po): Replace `msgmerge' with `$(MSGMERGE)'. + (po/%.mo): Replace `msgfmt' with `$(MSGFMT)'. + * po/LINGUAS: New file. + 2009-11-17 Robert Millan * configure.ac: Call AM_GNU_GETTEXT() (defines localedir, among diff --git a/Makefile.in b/Makefile.in index 07f0b6fec..a87ace29d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -41,7 +41,11 @@ includedir = @includedir@ pkgdatadir = $(datadir)/`echo @PACKAGE_TARNAME@ | sed '$(transform)'` pkglibdir = $(libdir)/`echo @PACKAGE_TARNAME@/$(target_cpu)-$(platform) | sed '$(transform)'` -LINGUAS = ca +XGETTEXT = @XGETTEXT@ +MSGMERGE = @MSGMERGE@ +MSGFMT = @MSGFMT@ + +LINGUAS = $(shell tr '\n' ' ' < $(srcdir)/po/LINGUAS) PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ @@ -467,14 +471,14 @@ genkernsyms.sh: genkernsyms.sh.in config.status $(SHELL) ./config.status po/$(PACKAGE).pot: po/POTFILES - xgettext --from-code=utf-8 --keyword=_ -f $< -o $@ + $(XGETTEXT) --from-code=utf-8 --keyword=_ -f $< -o $@ po/*.po: po/$(PACKAGE).pot - msgmerge -U $@ po/$(PACKAGE).pot + $(MSGMERGE) -U $@ po/$(PACKAGE).pot po/%.mo: po/%.po $(MKDIR_P) $$(dirname $@) - msgfmt -c --statistics -o $@ $^ + $(MSGFMT) -c --statistics -o $@ $^ .PHONY: all install install-strip uninstall clean mostlyclean distclean .PHONY: maintainer-clean info dvi dist check diff --git a/po/LINGUAS b/po/LINGUAS new file mode 100644 index 000000000..16fc6795f --- /dev/null +++ b/po/LINGUAS @@ -0,0 +1 @@ +ca From 5dd39a2f3bf0c90302dbab33f4a14f8d31741f55 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Tue, 17 Nov 2009 11:32:05 +0000 Subject: [PATCH 13/15] Use proper path for gettext.sh and export TEXTDOMAINDIR. --- util/grub.d/10_linux.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index 65daf0da6..8803055cf 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -18,11 +18,13 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ +bindir=@bindir@ libdir=@libdir@ . ${libdir}/grub/grub-mkconfig_lib -. /usr/bin/gettext.sh +. ${bindir}/gettext.sh export TEXTDOMAIN=@PACKAGE@ +export TEXTDOMAINDIR=@LOCALEDIR@ if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then OS=GNU/Linux From 37fb845ba6c5f55db5f8c4412305dbc99c661487 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Tue, 17 Nov 2009 11:44:43 +0000 Subject: [PATCH 14/15] 2009-11-17 Robert Millan * INSTALL: Document Automake is needed for bootstrap. * po/ca.po: Fix PO-Revision-Date and Language-Team fields. * util/grub.d/10_kfreebsd.in (bindir): New variable. Add gettext initialization. (kfreebsd_entry): Make menuentry output translatable. --- ChangeLog.gettext | 8 ++++++++ INSTALL | 1 + Makefile.in | 3 +-- po/ca.po | 4 ++-- util/grub.d/10_kfreebsd.in | 16 ++++++++++++---- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/ChangeLog.gettext b/ChangeLog.gettext index a1451f1d1..93b241b9e 100644 --- a/ChangeLog.gettext +++ b/ChangeLog.gettext @@ -1,3 +1,11 @@ +2009-11-17 Robert Millan + + * INSTALL: Document Automake is needed for bootstrap. + * po/ca.po: Fix PO-Revision-Date and Language-Team fields. + * util/grub.d/10_kfreebsd.in (bindir): New variable. + Add gettext initialization. + (kfreebsd_entry): Make menuentry output translatable. + 2009-11-17 Robert Millan * Makefile.in (XGETTEXT, MSGMERGE, MSGFMT, LINGUAS): New variables. diff --git a/INSTALL b/INSTALL index f9ae8f9d2..74bf3d490 100644 --- a/INSTALL +++ b/INSTALL @@ -22,6 +22,7 @@ need the following. * Ruby 1.6 or later * Autoconf 2.59d or later +* Automake 1.10.1 or later Configuring the GRUB ==================== diff --git a/Makefile.in b/Makefile.in index a87ace29d..febba1f33 100644 --- a/Makefile.in +++ b/Makefile.in @@ -47,14 +47,13 @@ MSGFMT = @MSGFMT@ LINGUAS = $(shell tr '\n' ' ' < $(srcdir)/po/LINGUAS) +PACKAGE = @PACKAGE@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE = @PACKAGE@ - host_os = @host_os@ host_kernel = @host_kernel@ host_cpu = @host_cpu@ diff --git a/po/ca.po b/po/ca.po index 4213346d4..69a44cdeb 100644 --- a/po/ca.po +++ b/po/ca.po @@ -7,9 +7,9 @@ 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" +"PO-Revision-Date: 2009-11-17 12:26+0100\n" "Last-Translator: Robert Millan \n" -"Language-Team: LANGUAGE \n" +"Language-Team: None \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/util/grub.d/10_kfreebsd.in b/util/grub.d/10_kfreebsd.in index cd8c186be..c6712e32f 100644 --- a/util/grub.d/10_kfreebsd.in +++ b/util/grub.d/10_kfreebsd.in @@ -18,9 +18,14 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ +bindir=@bindir@ libdir=@libdir@ . ${libdir}/grub/grub-mkconfig_lib +. ${bindir}/gettext.sh +export TEXTDOMAIN=@PACKAGE@ +export TEXTDOMAINDIR=@LOCALEDIR@ + case "${GRUB_DISTRIBUTOR}" in Debian) OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD" ;; *) OS="FreeBSD" ;; @@ -28,9 +33,12 @@ esac kfreebsd_entry () { - cat << EOF -menuentry "$1" { -EOF + os="$1" + version="$2" + recovery="$3" # not used yet + args="$4" # not used yet + title="$(gettext "%s, with kFreeBSD %s")" + printf "menuentry \"${title}\" {" ${os} ${version} if [ -z "${prepare_boot_cache}" ]; then prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")" fi @@ -100,7 +108,7 @@ while [ "x$list" != "x" ] ; do acpi_ko_rel_dirname=`make_system_path_relative_to_its_root $acpi_ko_dirname` fi - kfreebsd_entry "${OS}, kFreeBSD ${version}" + kfreebsd_entry "${OS}" "${version}" list=`echo $list | tr ' ' '\n' | grep -vx $kfreebsd | tr '\n' ' '` done From 16a976093398f39dca4882a5fb31fad397e4f38d Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Tue, 17 Nov 2009 11:55:04 +0000 Subject: [PATCH 15/15] Complete ChangeLog. --- ChangeLog.gettext | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/ChangeLog.gettext b/ChangeLog.gettext index 93b241b9e..b89a86d71 100644 --- a/ChangeLog.gettext +++ b/ChangeLog.gettext @@ -8,10 +8,11 @@ 2009-11-17 Robert Millan - * Makefile.in (XGETTEXT, MSGMERGE, MSGFMT, LINGUAS): New variables. + * Makefile.in (XGETTEXT, MSGMERGE, MSGFMT): New variables. (po/$(PACKAGE).pot): Replace `xgettext' with `$(XGETTEXT)'. (po/*.po): Replace `msgmerge' with `$(MSGMERGE)'. (po/%.mo): Replace `msgfmt' with `$(MSGFMT)'. + (LINGUAS): Auto-generate using `po/LINGUAS'. * po/LINGUAS: New file. 2009-11-17 Robert Millan @@ -43,3 +44,20 @@ * acinclude.m4: ... to here. * autogen.sh: Add call to `aclocal'. * configure.ac: Add AM_INIT_AUTOMAKE() after AC_INIT() call. + +2009-11-16 Robert Millan + + * Makefile.in (CLEANFILES): Add `po/*.mo'. + (LINGUAS): New variable. + (all-local): Add `$(foreach lang, $(LINGUAS), po/$(lang).mo)'. + (install-local): Install MO files. + (po/$(PACKAGE).pot, po/*.po, po/%.mo): New rules. + * include/grub/i18n.h: New file. + * po/POTFILES: New file. + * po/ca.po: New file. + * util/grub.d/10_linux.in (bindir): New variable. + Add gettext initialization. + (linux_entry): Make menuentry output translatable. + * util/i386/pc/grub-mkimage.c: Include `'. + (usage): Make --help output translatable. + (main): Initialize gettext.