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

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

Re: gettext and TemplateToolkit


From: Bruno Haible
Subject: Re: gettext and TemplateToolkit
Date: Sun, 1 Feb 2009 14:20:15 +0100
User-agent: KMail/1.9.9

Hello,

Nikolai Prokoschenko wrote:
> I've seen in gettext commit log that you are the main committer to
> gettext right now. Since gettext doesn't have a mailing list, I'd like
> to ask you to help me a bit.

gettext does have a mailing list: the "gettext --help" output lists one,
and the project page at https://savannah.gnu.org/projects/gettext/ lists
two more.

> I'm currently having a hard time using gettext with TemplateToolkit,
> i.e. not all marked strings get extracted. They look like this:
> 
> [% l('You are logged in as {username}', username => user.name) %]
> 
> l() is a macro which basically expands to gettext() and passes the
> hash (second argument) to a function which expands the values in the
> string. I use a simple "xgettext --keyword=l:1 ..." to extract this
> string, but somehow not every string gets extracted, even though they
> look the same. For plurals, I use
> 
> [% ln('{num} apple', '{num} apples', n, num => n) %]
> 
> with --keyword=ln:1,2.
> 
> Also I've noticed that xgettext without "--language=perl" (which
> probably shouldn't be necessary in this case) chuckles on Template
> Toolkit comments in the form:
> 
> [%# This next is a debug message, and shouldn't be translated %]
> 
> saying that a string is not properly quoted.
> 
> What am I doing wrong here, what can I do better?

Looking at http://template-toolkit.org/ it appears that "Template Toolkit"
is a language of its own, and not yet supported by xgettext. ("xgettext --help"
shows the list of supported languages.)

If you use --language=perl or no --language option at all, it's normal that
xgettext will extract according to the Perl syntax or to the syntax guessed
from the input file name.

xgettext supports PHP, which is structurally similar to Template Toolkit.
If you want xgettext to support this language, someone needs to write a file
like gettext/gettext-tools/src/x-php.c. In
  <http://template-toolkit.org/docs/manual/Syntax.html>
  <http://template-toolkit.org/docs/manual/Directives.html>
I see some formal description of the syntax. For an xgettext extractor module
one needs to know:
  - What are the file extensions associated with this language?
  - How to find the start and end of text that may contain gettext function
    calls?
  - What kinds of tokens exist, what kinds of characters can they contain?
  - In particular, how are literal strings written? What are its delimiters,
    and what escaping mechanism is used?
  - How do function calls look like?
  - What built-in functions call gettext?
And then, the gettext documentation should be updated...

Bruno





reply via email to

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