Rodrigo Moraes | 21 Jun 2012 02:24
Picon
Gravatar

gettext: a MO file parser

Hey,
I started to work on a package to deal with GNU Gettext. For now, it
can parse MO files:

    http://go.pkgdoc.org/code.google.com/p/gorilla/gettext

But it is still incomplete. It doesn't parse Plural-Forms, which will
require a whole expression parser [1]. It will have it soon, I
hope. :)

My wish is to gradually add gettext-related tools, like message
extraction from go files and templates and compilation of MO files.
We'll get there. Talk to me if you can help. :)

-- rodrigo

[1] http://www.gnu.org/software/gettext/manual/gettext.html#Plural-forms

Vasiliy Tolstov | 21 Jun 2012 11:17
Picon
Gravatar

Re: gettext: a MO file parser

2012/6/21 Rodrigo Moraes <rodrigo.moraes@...>:
> Hey,
> I started to work on a package to deal with GNU Gettext. For now, it
> can parse MO files:
>
>    http://go.pkgdoc.org/code.google.com/p/gorilla/gettext
>
> But it is still incomplete. It doesn't parse Plural-Forms, which will
> require a whole expression parser [1]. It will have it soon, I
> hope. :)
>
> My wish is to gradually add gettext-related tools, like message
> extraction from go files and templates and compilation of MO files.
> We'll get there. Talk to me if you can help. :)
>
> -- rodrigo
>
> [1] http://www.gnu.org/software/gettext/manual/gettext.html#Plural-forms

Great. But how can use this is web apps?

--

-- 
Vasiliy Tolstov,
Clodo.ru
e-mail: v.tolstov@...
jabber: vase@...

Rodrigo Moraes | 21 Jun 2012 12:07
Picon
Gravatar

Re: gettext: a MO file parser

On Jun 21, 6:17 am, Vasiliy Tolstov wrote:
> Great. But how can use this is web apps?

It is still very raw. Basically all user-facing strings in templates
and go files need to be wrapped to a call to Catalog.Gettext() or
Ngettext(). Then you need to extract those messages from templates and
go files, then translate them and compile into MO files. Then based on
the request (URL, cookie, user preferences) you select the right
catalog to translate messages.

The plan is that it'll eventually have the tools for the full
workflow, but for now it just reads compiled catalogs. :)

-- rodrigo

LRN | 21 Jun 2012 12:10
Picon
Gravatar

Re: gettext: a MO file parser

On Thursday, June 21, 2012 1:17:07 PM UTC+4, Vasiliy Tolstov wrote:

Great. But how can use this is web apps?
Well, i assume that there will be a way for the user to change the language on the fly, and gettext would fetch translations from a different catalogue. See [1] for how this is done in GNU gettext

[1] http://www.gnu.org/software/gettext/manual/gettext.html#gettext-grok


Gmane