lua-users home
lua-l archive

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


Hi Marc,

> 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...

I have implemented internationalization support in ZeroBrane Studio
and did exactly what Steve describes: I have TR("string") function
that plays a dual role of translating a string and also serving as a
marker that allows me to extract all strings that require translation
from the source code.

I described the details of the implementation in an earlier thread:
http://lua-users.org/lists/lua-l/2013-02/msg00106.html

The Lua script I have does both of those things you are asking about:
it extracts all strings wrapped into TR calls, but it also "merges"
them with an existing translation file and will even mark those
translation that might have been modified, so it can be used to
quickly check what strings have been added/updated and need to be
translated.

This mechanism has been working well for the project and I haven't
seen any issues related to it; it has been so far translated to six
languages: http://notebook.kulchenko.com/zerobrane/zerobrane-studio-in-seven-languages.

Paul.

On Thu, Jul 25, 2013 at 1: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...
>