[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: [ANN] using parser of MO files to translate Lapis site
- From: Nagaev Boris <bnagaev@...>
- Date: Mon, 11 May 2015 01:12:00 +0000
I am pleased to announce that I have packaged the parser of MO files
and uploaded it to luarocks as package "mo".
Installation: luarocks install mo
MO file is binary translations format of GNU gettext. It is created
from PO file using tool msgfmt. It can be used to translate an
application or a site from English to other language.
J.Jørgen von Bargen have uploaded the code of parser to this mailing
list on Apr, 01, 2010 . I have changed behavior of the function:
now it returns translating function in case of success and
(function(x) return x end) in case of errors. Unit tests were added.
Package was uploaded to luarocks as "mo".
I use this package in code of my site kodomoquiz.tk , based on
Lapis . "mo" is used in many files of that project, e.g. in file
"app.lua" (as variable "_").
Let us translate some Lua project into Russian.
$ xgettext -p ru -s -j --language=Lua *.lua --from-code utf-8
This command creates (or adds to) file ru/messages.po. It finds texts
like _("text") in source files and adds them to .po file.
There are a lot of programs to translate .po file. One of them is poedit.
To compile .po to .mo, run the following command:
$ msgfmt ru/messages.po -o ru/messages.mo
This module is used to parse .mo file from Lua.