lua-users home
lua-l archive

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


Sputnik uses this rather simple module:

https://github.com/yuri/sputnik/blob/master/sputnik/lua/sputnik/i18n.lua

It really just relies on looking up translations in a table, but it
adds system for fallback locales (where you can say that pt_PT is
fallback for pt_BR and en_US is the fallback for pt_BR).

Also, there is this module that looks quite promising.

https://github.com/kikito/i18n.lua/

It's quite a bit more involved and supports pluralization, including
for languages with tricky rules (like different forms of plural for
small and large numbers).

  - yuri

On Thu, Jul 25, 2013 at 4:51 AM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> On Thu, Jul 25, 2013 at 10:19 AM, Marc Balmer <marc@msys.ch> wrote:
>>
>> Any hints welcome!
>
>
> Extracting strings from Lua sources is not difficult, especially with lpeg
> (or a simple Lua tokenizer such as in Penlight).
>
> One just has to choose a convention, e.g double-quoted strings will be seen
> by users, single-quoted strings are internal.
>
> But then, why not define a function such as L so that L"Hello World" will do
> the appropriate lookup?  First pass will return "Hello Word" but also create
> an entry in localization table(s).
>
> Lua programs that I know of with internalization support are Sputnik and
> ZeroBrane studio, so perhaps Yury Y and Paul K can speak about that...
>