tech-install archive

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

Re: reworking sysinst: A Lua based msg system

Am 04.03.12 12:35, schrieb Martin Husemann:
> On Sun, Mar 04, 2012 at 12:24:59PM +0100, Marc Balmer wrote:
>> - support for easy translation into foreign languages
>> - support dynamically created message that contain variables
>> - be modular insfar as sysinst extension modules can come with their own
>> set of (translated) messages
> Why are you not using existing functionality for this (like catopen(3))?
> I don't mean to imply that this would be a better solution, but the
> reasoning should be made explicit and clear.

I want to eliminate the need to process messages in any form prior to
using them.  The goal is make things as easy as possible for users, Lua
being the only tool a user must know.

>> Message catalogs
>>      Messages are organized in message catalogs, one catalog per language.
>> Once a language has been selected by the users, only that message
>> catalog is used.  Message catalogs are Lua tables and a Lua script can
>> add its messages by calling the msg() function:
>> msg('english', {greeting = 'Hello', monday = 'Monday'})
>> msg('german', {greeting = 'Guten Tag', monday = 'Montag'})
> Messages are data, not program code - keep them separate.

Message _are_ data.  They are organized in Lua tables, the msg()
function takes such a table and adds it to the respective language
message catalog (stuff in {} is a Lua table).  Keep in mind that Lua was
designed as a data description language and has a powerful syntax for that.

> How do you identify messages in your code? By index?

By index:

msg('english', { monday = 'Monday'})


> Besides the "modules need to be able to add messages (including translations)"
> property you cited above, there are two tremendously important properties
> a new scheme should provide:
>  - if a translation is missing, automatically fall back to english
>    (so a new message can be added as english only and native translators
>     can pick it up later)

Yes, in the end it has to work this way.  The Lua pseudocode for this
could be sth like

if _M.mymsg == nil then
   return _M.english.mymsg
   return _M.mymsg

>  - there needs to be an easy method to query all the tables for missing
>    translations for a give language, i.e. something like 
>       make list-missing-translations LANG=de
>    and it would print the identification and english text of all messages
>    that have no german translation yet

That could probably be done in sysinst itself.

Home | Main Index | Thread Index | Old Index