gettext: a MO file parser

584 views
Skip to first unread message

Rodrigo Moraes

unread,
Jun 20, 2012, 8:24:11 PM6/20/12
to golang-nuts
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

unread,
Jun 21, 2012, 5:17:07 AM6/21/12
to Rodrigo Moraes, golang-nuts
2012/6/21 Rodrigo Moraes <rodrigo...@gmail.com>:
Great. But how can use this is web apps?

--
Vasiliy Tolstov,
Clodo.ru
e-mail: v.to...@selfip.ru
jabber: va...@selfip.ru

Rodrigo Moraes

unread,
Jun 21, 2012, 6:07:07 AM6/21/12
to golang-nuts
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

unread,
Jun 21, 2012, 6:10:51 AM6/21/12
to golan...@googlegroups.com
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

Reply all
Reply to author
Forward
0 new messages