lua-users home
lua-l archive

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

Just submitted a pull request :)

On Sun, May 10, 2015 at 6:12 PM, Nagaev Boris <> wrote:

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
License: MIT

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 [1]. 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 [2], based on
Lapis [3]. "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/

This module is used to parse .mo file from Lua.



Best regards,
Boris Nagaev

Brigham Toskin