root/mirror/edenwall/nulog2/branches/2.0/doc/gettext.rst

Revision 8111, 1.1 kB (checked in by haypo, 3 years ago)

Use foo/bar in examples

  • Property svn:mime-type set to text/x-rst; charset=utf8

GETTEXT

1   How to update .po files

First you have to go in nulog-web directory, and enter this command:

$ ./update-l10n

If will display all fuzzed and newest entries for all languages.

Translate them in po/<lang>/LC_MESSAGES/nulog.po and type this to update .mo files:

$ ./update-l10n

2   When do I use _()

With Nevow, you CAN'T use _() in loaders.stan().

You might use ctx.tag.clear()[] instead.

3   The trans() function

_() doesn't return a string with translation, but a PlaceHolder object.

When you want to do something like:

string = '%s bar' % _('foo')

It will fail.

Nulog defines a function in nulog-web/tools.py, trans(), to do this.

You might call this function with:

string = '%s bar' % trans(ctx, _('foo'))

ctx is a Context object which contains the informations about user and in what language we must translate it.

Note that it is usefull here, because when you use _(), translation is made by Nevow. Here, we do translation ourselve, so we have to know the context.

Note: See TracBrowser for help on using the browser.