[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Working gettext example for grub.cfg?

From: Andrey Borzenkov
Subject: Re: Working gettext example for grub.cfg?
Date: Thu, 28 Feb 2013 06:57:03 +0400

В Wed, 27 Feb 2013 10:42:50 +0100
Ronny Standtke <address@hidden> пишет:

> Hi all
> I was excited to see that grub2 has a build-in gettext command.
> I am trying to build a grub.cfg that makes use of this feature so that
> users of our distribution (based on Debian Live) can switch the grub
> menu to their language. Unfortunately, I completely failed to produce
> even the simplest working example, e.g. assigning translated text to a
> variable. I tried many combinations:
> -----------------
> TRANSLATED=gettext "foo"
> TRANSLATED=$(gettext "foo")
> TRANSLATED="$(gettext "foo")"
> ...
> -----------------

No, that's does not work. GRUB is not shell.

To translate string in grub.cfg you can use $"..." variable
substitution. It is basically the same as in bash, including variable
handling. I.e. in

$"This is ${foo} and this is ${bar}"

first the string as a whole is translated and then $foo and $bar are
substituted with their values.

> All attempts ended in either $TRANSLATED holding just the text "gettext"
> or in syntax errors.
> Could you please provide a simple working example of the gettext feature
> in a grub.cfg script?

I started to look at moving grub.cfg translation to runtime, but the
primary problem I hit - distributed grub-mkconfig builds entry titles
with variable parts, computed when grub-mkconfig runs. I.e. 

submenu 'Advanced options for openSUSE 12.2'

here "openSUSE 12.2" is variable which depends on current system. This
makes it rather awkward to use $"..." translation. Think about

menuentry $"Here is fix part, comes ${_title_var1} followed by
${_title_var2} ..."


Alternative is to split translated and untranslated parts, like

submenu $"Advanced options for"" openSUSE 12.2"

but obvious problem here, some languages may need "openSUSE 12.2" in
different part of sentence.

So it is more or less trivial to move translation for everything except
menu titles into grub.cfg, it is just mechanical work (and translation
strings have to be replace of course; that is another issue. May be,
making $"..." replace ${var} with %s could allow to reuse them). But
for titles I do not have idea that I like currently.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]