[ANN] using parser of MO files to translate Lapis site

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[ANN] using parser of MO files to translate Lapis site

Nagaev Boris
Hello,

I am pleased to announce that I have packaged the parser of MO files
and uploaded it to luarocks as package "mo".

Homepage: https://github.com/starius/mo.lua
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 kodomoquiz.tk [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/messages.mo

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


[1] http://lua-users.org/lists/lua-l/2010-04/msg00005.html
[2] https://github.com/starius/kodomoquiz
[3] http://leafo.net/lapis/

--


Best regards,
Boris Nagaev

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] using parser of MO files to translate Lapis site

Brigham Toskin
Just submitted a pull request :)


On Sun, May 10, 2015 at 6:12 PM, Nagaev Boris <[hidden email]> wrote:
Hello,

I am pleased to announce that I have packaged the parser of MO files
and uploaded it to luarocks as package "mo".

Homepage: https://github.com/starius/mo.lua
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 kodomoquiz.tk [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/messages.mo

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


[1] http://lua-users.org/lists/lua-l/2010-04/msg00005.html
[2] https://github.com/starius/kodomoquiz
[3] http://leafo.net/lapis/

--


Best regards,
Boris Nagaev




--
Brigham Toskin
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] using parser of MO files to translate Lapis site

Nagaev Boris
On Mon, May 11, 2015 at 10:19 PM, Brigham Toskin
<[hidden email]> wrote:
> Just submitted a pull request :)
>
> https://github.com/starius/mo.lua/pull/2

Thank you! Merged. Now mo.lua returns error string as second result
value in case of error. Trivial function remains as first result
value.

Version 1.1 was released and uploaded to luarocks.

>
> On Sun, May 10, 2015 at 6:12 PM, Nagaev Boris <[hidden email]> wrote:
>>
>> Hello,
>>
>> I am pleased to announce that I have packaged the parser of MO files
>> and uploaded it to luarocks as package "mo".
>>
>> Homepage: https://github.com/starius/mo.lua
>> 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 kodomoquiz.tk [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/messages.mo
>>
>> This module is used to parse .mo file from Lua.
>>
>>
>> [1] http://lua-users.org/lists/lua-l/2010-04/msg00005.html
>> [2] https://github.com/starius/kodomoquiz
>> [3] http://leafo.net/lapis/
>>
>> --
>>
>>
>> Best regards,
>> Boris Nagaev
>>
>
>
>
> --
> Brigham Toskin



--


Best regards,
Boris Nagaev

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] using parser of MO files to translate Lapis site

Brigham Toskin
On Tue, May 12, 2015 at 12:15 AM, Nagaev Boris <[hidden email]> wrote:
On Mon, May 11, 2015 at 10:19 PM, Brigham Toskin
<[hidden email]> wrote:
> Just submitted a pull request :)
>
> https://github.com/starius/mo.lua/pull/2

Thank you! Merged. Now mo.lua returns error string as second result
value in case of error. Trivial function remains as first result
value.

Version 1.1 was released and uploaded to luarocks.

Just thought I'd point out, so this is archived online, that this *could* be a breaking change if anyone using version 1.0 depends on the assumption that only a single result is ever returned, i.e. assigning it to variables or passing to a function with a second optional param (or vararg); I can't think of a reasonable code example that would fall prey to this, but be advised.

--
Brigham Toskin