lua-users home
lua-l archive

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


Hello everyone,

I have scanned the list and Googled for an answer without heaps of success so please bear with me if this has been asked before recently.

I am in the process of adding Internationalization (i18n) to my application, and been investigating gettext and other methods of translating strings.

Having had modest success with my main program, I am now turning my attention to Lua as my app uses it for scripting.

As far as I can see, there is no provision for making Lua more gettext-friendly. Thus, I make the following suggestion:

For error messages (in particular) which are currently in English, it would be helpful if the developers could surround them by a simple macro, which could aid production of a gettext translation template.

For example, instead of:

  luaL_error(L, "invalid format (repeated flags)");

... you would have:

  luaL_error(L, _TR("invalid format (repeated flags)"));

The exact name of the macro isn't important. In the include file you can then declare:

#define _TR(string) (string)

Thus effectively, from Lua's point of view, this becomes a no-op, which does not alter or slow down execution in any way.

However then you can do a "pass" over the source using xgettext, and extract out all the error messages into a translation template file. This could be used to automatically translate the errors from one language to another. For example, an implementor might change _TR to actually do the translation when required.

There are some issues, such as formatted error strings, and the fairly extensive use of the LUA_QL macro, however these could be overcome.

Are there any major objections? Do all Lua developers use English? Or would it be helpful?

Regards,

- Nick Gammon