bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: xgettext do not extract strings correctly from bash script


From: Bruno Haible
Subject: Re: xgettext do not extract strings correctly from bash script
Date: Tue, 11 Mar 2008 00:08:43 +0100
User-agent: KMail/1.5.4

Aurélio A. Heckert wrote:
> Hi, there are a little bug:
> 
> I need to set strings like that to to have a more readable code:
> gettext -s This is a test! It\'s not working :-\(
> ...but the xgettext give this po code:
> #: test.sh:21
> msgid "-s"
> msgstr ""

Indeed, it should ideally not create an msgid for "-s".

The fact that it does not extract "This" etc. is because you did not specify
a -d option here.

If you specified a -d option,

  gettext -d myprog -s This is a test! It\'s not working :-\(

then the strings being translated are "This", "is", "a", "test!", etc.
This is not reasonable internationalization: The translator should have to
translate entire sentences, not individual words. See the gettext doc:
  "Gettext > Preparing Program Sources > Preparing Translatable Strings"
  http://www.gnu.org/software/gettext/manual/html_node/Preparing-Strings.html

Now, if xgettext would behave "ideally", it would have to parse the options that
you specify. That would be a lot of work. I'm therefore only documenting the
limitation.

The recommended way to use gettext in shell scripts is through the eval_gettext
function; see the doc
  "Gettext > Other Programming Languages > Individual Programming Languages > 
sh"
  http://www.gnu.org/software/gettext/manual/html_node/sh.html

Bruno


2008-03-10  Bruno Haible  <address@hidden>

        * gettext.texi (gettext Invocation): Mention that xgettext does not
        support the various options.
        (ngettext Invocation): Likewise.
        Reported by Aurélio A. Heckert <address@hidden>.

*** gettext.texi        26 Dec 2007 16:02:00 -0000      1.148
--- gettext.texi        10 Mar 2008 22:56:23 -0000
***************
*** 9325,9335 ****
--- 9325,9343 ----
  
  @include rt-gettext.texi
  
+ Note: @code{xgettext} supports only the one-argument form of the
+ @code{gettext} invocation, where no options are present and the
+ @var{textdomain} is implicit, from the environment.
+ 
  @node ngettext Invocation, envsubst Invocation, gettext Invocation, sh
  @subsubsection Invoking the @code{ngettext} program
  
  @include rt-ngettext.texi
  
+ Note: @code{xgettext} supports only the three-arguments form of the
+ @code{ngettext} invocation, where no options are present and the
+ @var{textdomain} is implicit, from the environment.
+ 
  @node envsubst Invocation, eval_gettext Invocation, ngettext Invocation, sh
  @subsubsection Invoking the @code{envsubst} program
  





reply via email to

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