lua-users home
lua-l archive

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


On Thu, Jan 13, 2011 at 2:36 AM, Robert G. Jakabosky
<bobby@sharedrealm.com> wrote:
> [...]
> or you could use a function to make the lookup nicer:
> current_locale = "en_US"
> t = function(text)
>  local tr_locale = tr[current_locale] or tr.default
>  return tr_locale[text] or text
> end
> [...]
> Instead of a function named t you could use an underscore _.  I think some
> C/C++ based translation library (maybe QT) uses this _("hello") for
> translating text.

Uh oh, maybe unless you commonly use _ as a marker for "dummy variable
to assign to", as in:
  for _, v in ipairs(tab) do --[[ something ]]-- end
or:
  local x, _, z = fooBar()
- then I wouldn't advise _ for i18n as you might get some some issues
because of variable scoping...

Actually, I thought this use of _ (as "dummy") is common and suggested
by PIL, but now after what you wrote, I'm starting to lose my
certainity... do I regularly follow some non-standard practice?

greetings
Mateusz Czapliński