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 diff --git a/ChangeLog b/ChangeLog index ac8bed734..6d7a25be4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,67 @@ +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): 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 + + * 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). + * 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. + +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. + +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. + 2009-11-17 Robert Millan * import_gcry.py: New file (written by Vladimir with minor diff --git a/INSTALL b/INSTALL index d1d17d1b5..e7f9e8936 100644 --- a/INSTALL +++ b/INSTALL @@ -23,6 +23,7 @@ need the following. * Ruby 1.6 or later * Python 2.5.2 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 89d5189eb..febba1f33 100644 --- a/Makefile.in +++ b/Makefile.in @@ -41,6 +41,13 @@ includedir = @includedir@ pkgdatadir = $(datadir)/`echo @PACKAGE_TARNAME@ | sed '$(transform)'` pkglibdir = $(libdir)/`echo @PACKAGE_TARNAME@/$(target_cpu)-$(platform) | sed '$(transform)'` +XGETTEXT = @XGETTEXT@ +MSGMERGE = @MSGMERGE@ +MSGFMT = @MSGFMT@ + +LINGUAS = $(shell tr '\n' ' ' < $(srcdir)/po/LINGUAS) + +PACKAGE = @PACKAGE@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ @@ -67,8 +74,8 @@ CC = @CC@ CFLAGS = @CFLAGS@ ASFLAGS = @ASFLAGS@ LDFLAGS = @LDFLAGS@ -CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/include -Wall -W \ - -DGRUB_LIBDIR=\"$(pkglibdir)\" +CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/gnulib -I$(srcdir)/include -Wall -W \ + -DGRUB_LIBDIR=\"$(pkglibdir)\" -DLOCALEDIR=\"$(localedir)\" TARGET_CC = @TARGET_CC@ TARGET_CFLAGS = @TARGET_CFLAGS@ TARGET_ASFLAGS = @TARGET_ASFLAGS@ @@ -153,7 +160,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 +244,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 +308,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/$(PACKAGE).mo; \ + done) $(SHELL) $(mkinstalldirs) $(DESTDIR)$(infodir) @list='$(info_INFOS)'; \ for file in $$list; do \ @@ -455,6 +469,16 @@ gensymlist.sh: gensymlist.sh.in config.status genkernsyms.sh: genkernsyms.sh.in config.status $(SHELL) ./config.status +po/$(PACKAGE).pot: po/POTFILES + $(XGETTEXT) --from-code=utf-8 --keyword=_ -f $< -o $@ + +po/*.po: po/$(PACKAGE).pot + $(MSGMERGE) -U $@ po/$(PACKAGE).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/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 94322b15e..5cbdbb489 100755 --- a/autogen.sh +++ b/autogen.sh @@ -2,6 +2,7 @@ set -e +aclocal autoconf autoheader diff --git a/conf/common.rmk b/conf/common.rmk index 54bec37b0..9888ab7e0 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -39,7 +39,7 @@ grub_mkisofs_SOURCES = util/mkisofs/eltorito.c \ gnulib/fnmatch.c gnulib/getopt1.c gnulib/getopt.c \ gnulib/error.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. diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index 90bc2b2e3..e332700ff 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/configure.ac b/configure.ac index 6287c4f59..587f2118d 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,8 @@ 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/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/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/po/LINGUAS b/po/LINGUAS new file mode 100644 index 000000000..16fc6795f --- /dev/null +++ b/po/LINGUAS @@ -0,0 +1 @@ +ca 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..69a44cdeb --- /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: 2009-11-17 12:26+0100\n" +"Last-Translator: Robert Millan \n" +"Language-Team: None \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/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 diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index f17955846..8803055cf 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.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@ + if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then OS=GNU/Linux else @@ -44,15 +49,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 +107,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 diff --git a/util/i386/pc/grub-mkimage.c b/util/i386/pc/grub-mkimage.c index 15168f8fa..2001804c3 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 @@ -36,6 +37,8 @@ #define _GNU_SOURCE 1 #include +#include "progname.h" + #ifdef ENABLE_LZMA #include @@ -315,7 +318,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"), program_name); else printf ("\ Usage: grub-mkimage [OPTION]... [MODULES]\n\ @@ -347,7 +350,10 @@ main (int argc, char *argv[]) char *config = NULL; FILE *fp = stdout; - progname = "grub-mkimage"; + set_program_name (argv[0]); + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); while (1) {