lua-users home
lua-l archive

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


On Dec 13, 2007 10:37 AM, Eric Tetz <erictetz@gmail.com> wrote:
On Dec 13, 2007 6:35 AM, Brett Kugler <bkugler@gmail.com> wrote:
> First I have stringent memory limits I must stay within.  My concern with
> creating new variables for each string would be that my heap burden would
> grow significantly.

If that's a concern then you don't want to have every translation in
memory at the same time, as all the schemes we've been playing around
with have done.

The real KISS approach is just to load a file like:

  -- localizations.lua
  if language == "German" then
     DidNotWork = "Operasie het nie geslaag nie"
     NoAnswer = "Antwoord nie gefind nie"
  elseif language == "Martian" then
     DidNotWork = "Pqfsbtjf!ifu!ojf!hftmbbh!ojf"
     NoAnswer = "Bouxppse!ojf!hfgjoe!ojf"
  else -- default to English
     DidNotWork = "Operation did not succeed"
     NoAnswer = "No answer found"
  end

  -- yourapp.lua
  language = "German"
  dofile("localizations.lua")
  ...
  print(DidNotWork)
  print(NoAnswer)

Then you have *one* set of text and some relatively short identifier
names loaded in memory.

Cheers,
Eric

Yeah, the table was more a simplification for the discussion vs. something I was actually planning on implementing.

Brett