lua-users home
lua-l archive

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


To ease even more the use of a L function (or any other name you see fit), you can use a token filter to add it to all strings. Since you'll probably some strings to be untranslated (all strings that are not UI strings), you can make the token filter only add the L prefix to strings using double quotes, and let strings using simple quotes go untranslated (I don't know if a token filter can distinguish between the two, but that would be a nice addition if it doesn't).


From: lua-bounces@bazar2.conectiva.com.br [mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Brett Kugler
Sent: Wednesday, December 12, 2007 7:17 PM
To: Lua list
Subject: Re: String access & metamethods

Yes, in the end I agree.  The __tostring thing is neat, but it fails to work in instances outside of print() etc.  So the original translation function L would seem to meet my needs the best.

Again, I thank all of you for your comments and help.

Brett

On Dec 12, 2007 5:50 PM, Miles Bader <miles@gnu.org> wrote:
"Carlos Augusto Teixeira Mendes" <cmendes@k2sistemas.com.br> writes:
> you will get <<<foobar>>>
>
> and not <<<foo>>><<<bar>>> as you might be expecting for your translation
> requirements.

Yeah, I think for this sort of task, you really want _source_ strings to
be translated.

I think it's better to byte the bullet and use the prefix (e.g. L"...")
though, because translating _every_ string by default seems way too
dangerous.  Some strings are not meant to be translated, and only the
programmer really knows which is which.

[Consider:

  display_dialog_box ("succeeded")

versus

  if output_of_some_script == "succeeded" then
     ...
  end

It's pretty likely the first should be translated but not the second.]

-Miles

--
`Cars give people wonderful freedom and increase their opportunities.
 But they also destroy the environment, to an extent so drastic that
 they kill all social life' (from _A Pattern Language_)