]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* util/grub-mkconfig_lib.in (gettext_quoted): Add clarifying
authorColin Watson <cjwatson@ubuntu.com>
Tue, 21 Dec 2010 12:49:29 +0000 (12:49 +0000)
committerColin Watson <cjwatson@ubuntu.com>
Tue, 21 Dec 2010 12:49:29 +0000 (12:49 +0000)
comment.  Add an extra layer of quotation, requiring the output of
this function to be used in a printf format string.
(gettext_printf): New function.
* util/grub.d/10_hurd.in: Use gettext_printf where appropriate.
Extract translatable strings from here-documents and use a temporary
variable instead, so that xgettext can find them.
* util/grub.d/10_kfreebsd.in: Likewise.
* util/grub.d/10_linux.in: Likewise.
* util/grub.d/20_linux_xen.in: Likewise.

* po/grub.d.sed: New file.
* po/Makefile.in.in ($(DOMAIN).pot-update): Extract gettext_printf
arguments.  Set c-format flags on all strings extracted from
util/grub.d/ (xgettext refuses to include these itself for strings
it extracted from a shell file, but these really are c-format).

ChangeLog
po/Makefile.in.in
po/grub.d.sed [new file with mode: 0644]
util/grub-mkconfig_lib.in
util/grub.d/10_hurd.in
util/grub.d/10_kfreebsd.in
util/grub.d/10_linux.in
util/grub.d/20_linux_xen.in

index 6e564324b4d2e7b26f193cbd9aeefa99d21ac52b..ca555a6628ad5685de807d56158e7a7b7699c95c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2010-12-21  Colin Watson  <cjwatson@ubuntu.com>
+
+       * util/grub-mkconfig_lib.in (gettext_quoted): Add clarifying
+       comment.  Add an extra layer of quotation, requiring the output of
+       this function to be used in a printf format string.
+       (gettext_printf): New function.
+       * util/grub.d/10_hurd.in: Use gettext_printf where appropriate.
+       Extract translatable strings from here-documents and use a temporary
+       variable instead, so that xgettext can find them.
+       * util/grub.d/10_kfreebsd.in: Likewise.
+       * util/grub.d/10_linux.in: Likewise.
+       * util/grub.d/20_linux_xen.in: Likewise.
+
+       * po/grub.d.sed: New file.
+       * po/Makefile.in.in ($(DOMAIN).pot-update): Extract gettext_printf
+       arguments.  Set c-format flags on all strings extracted from
+       util/grub.d/ (xgettext refuses to include these itself for strings
+       it extracted from a shell file, but these really are c-format).
+
 2010-12-20  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_add_module):
index d0af6c9620d3d4c31bcd3b9d8e829c71fb0046cc..b0e7b8fa25c9ebac49c7d9abdf0b99466490b20a 100644 (file)
@@ -173,7 +173,8 @@ $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in $(srcdir)/POTFILES-shell
              --files-from=$(srcdir)/POTFILES-shell.in \
              --copyright-holder='$(COPYRIGHT_HOLDER)' \
              --msgid-bugs-address="$$msgid_bugs_address" \
-             --join-existing --language=Shell --keyword=gettext_quoted \
+             --join-existing --language=Shell \
+             --keyword=gettext_quoted --keyword=gettext_printf \
            ;; \
          *) \
            $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
@@ -183,10 +184,13 @@ $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in $(srcdir)/POTFILES-shell
              --package-name="$${package_gnu}@PACKAGE@" \
              --package-version='@VERSION@' \
              --msgid-bugs-address="$$msgid_bugs_address" \
-             --join-existing --language=Shell --keyword=gettext_quoted \
+             --join-existing --language=Shell \
+             --keyword=gettext_quoted --keyword=gettext_printf \
            ;; \
        esac
        test ! -f $(DOMAIN).po || { \
+         sed -f grub.d.sed < $(DOMAIN).po > $(DOMAIN).1po && \
+         mv $(DOMAIN).1po $(DOMAIN).po; \
          if test -f $(srcdir)/$(DOMAIN).pot; then \
            sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
            sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
diff --git a/po/grub.d.sed b/po/grub.d.sed
new file mode 100644 (file)
index 0000000..9fd7294
--- /dev/null
@@ -0,0 +1,2 @@
+/^#: util\/grub\.d\//a\
+#, c-format
index 41359975e85e7660aca232f45eed4ff1d029930f..ec4084698de26c1b89608dfcd9d75e8a6c6704eb 100644 (file)
@@ -187,8 +187,20 @@ version_find_latest ()
   echo "$a"
 }
 
+# One layer of quotation is eaten by "", the second by sed, and the third by
+# printf; so this turns ' into \'.  Note that you must use the output of
+# this function in a printf format string.
 gettext_quoted () {
-  $gettext "$@" | sed "s/'/'\\\\''/g"
+  $gettext "$@" | sed "s/'/'\\\\\\\\''/g"
+}
+
+# Run the first argument through gettext_quoted, and then pass that and all
+# remaining arguments to printf.  This is a useful abbreviation and tends to
+# be easier to type.
+gettext_printf () {
+  local format="$1"
+  shift
+  printf "$(gettext_quoted "$format")" "$@"
 }
 
 uses_abstraction () {
index 6490913aeb5c050e26f7ac4a48ae512f5b75641b..eeb441aa4cceaf7f02938e7e1c171805553ee203 100644 (file)
@@ -81,14 +81,16 @@ do
 menuentry "${OS} ${KERNEL}" ${CLASS} {
 EOF
   prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
+  message="$(gettext_printf "Loading GNU Mach ...")"
   cat << EOF
-       echo            '$(gettext_quoted "Loading GNU Mach ...")'
+       echo            '$message'
        multiboot       ${kernel} root=device:${GRUB_DEVICE#/dev/}
 EOF
   save_default_entry | sed -e "s/^/\t/"
   prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/"
+  message="$(gettext_printf "Loading the Hurd ...")"
   cat << EOF
-       echo            '$(gettext_quoted "Loading the Hurd ...")'
+       echo            '$message'
        module          /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\
                        --multiboot-command-line='\${kernel-command-line}' \\
                        --host-priv-port='\${host-port}' \\
@@ -103,13 +105,15 @@ EOF
 menuentry "${OS} ${KERNEL} (recovery mode)" ${CLASS} {
 EOF
   prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/"
+  message="$(gettext_printf "Loading GNU Mach ...")"
   cat << EOF
-       echo            '$(gettext_quoted "Loading GNU Mach ...")'
+       echo            '$message'
        multiboot       ${kernel} root=device:${GRUB_DEVICE#/dev/} -s
 EOF
   prepare_grub_to_access_device ${GRUB_DEVICE} | sed -e "s/^/\t/"
+  message="$(gettext_printf "Loading the Hurd ...")"
   cat << EOF
-       echo            '$(gettext_quoted "Loading the Hurd ...")'
+       echo            '$message'
        module          /hurd/${hurd_fs}.static ${hurd_fs} \\
                        --multiboot-command-line='\${kernel-command-line}' \\
                        --host-priv-port='\${host-port}' \\
index 9cb2788dfba878317938852d162d7512b24853a4..b026812a7f01fa3c43dc4acdcbf6a83dde5d3f20 100644 (file)
@@ -84,8 +84,9 @@ kfreebsd_entry ()
   fi
 
   printf '%s\n' "${prepare_boot_cache}"
+  message="$(gettext_printf "Loading kernel of FreeBSD %s ..." ${version})"
   cat << EOF
-       echo                    '$(printf "$(gettext_quoted "Loading kernel of FreeBSD %s ...")" ${version})'
+       echo                    '$message'
        kfreebsd                ${rel_dirname}/${basename} ${args}
 EOF
 
index 7650ac9fa467c1864db17304e05f7d2df075421a..a09c3e687709ae60a571a3be783790cf0092c5e5 100644 (file)
@@ -94,13 +94,15 @@ EOF
     prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
   fi
   printf '%s\n' "${prepare_boot_cache}"
+  message="$(gettext_printf "Loading Linux %s ..." ${version})"
   cat << EOF
-       echo    '$(printf "$(gettext_quoted "Loading Linux %s ...")" ${version})'
+       echo    '$message'
        linux   ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
 EOF
   if test -n "${initrd}" ; then
+    message="$(gettext_printf "Loading initial ramdisk ...")"
     cat << EOF
-       echo    '$(gettext_quoted "Loading initial ramdisk ...")'
+       echo    '$message'
        initrd  ${rel_dirname}/${initrd}
 EOF
   fi
index 649ae85dd1d9895f2c7967fe0fed09f1b4844baa..a90211f44cdb1ceb96229a256b1956dc4f8679ca 100644 (file)
@@ -73,14 +73,16 @@ linux_entry ()
     prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
   fi
   printf '%s\n' "${prepare_boot_cache}"
+  message="$(gettext_printf "Loading Linux %s ..." ${version})"
   cat << EOF
-       echo    '$(printf "$(gettext_quoted "Loading Linux %s ...")" ${version})'
+       echo    '$message'
        multiboot       ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args}
        module  ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args}
 EOF
   if test -n "${initrd}" ; then
+    message="$(gettext_printf "Loading initial ramdisk ...")"
     cat << EOF
-       echo    '$(gettext_quoted "Loading initial ramdisk ...")'
+       echo    '$message'
        module  ${rel_dirname}/${initrd}
 EOF
   fi