lua-users home
lua-l archive

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


Am 05.01.2013 um 18:26 schrieb steve donovan <steve.j.donovan@gmail.com>:

> On Sat, Jan 5, 2013 at 6:33 PM, Alexander Gladysh <agladysh@gmail.com> wrote:
>> But IMO in i18n it is often better to use named placeholders, not
>> positional ones.
> 
> Yes, much more readable. I tend to get mixed up with more than two %s
> formats in a string
> 
> Microlight's expand function does this - it's genuinely a three-liner

It was an experiment only.  When I do

print(_('%s - %d', 'foo', 42))

I wanted this to use a different format string, with optional different ordering.  Having a table entry like

['%s - %d'] = { '%d - %s', 2, 1}

So I am indicating a replacement format string and a new order of parameters.

And that works.  Whether it is a good solution is a different question (it's not used anywhere right now)

Thanks for all hints and comments, btw.