lua-users home
lua-l archive

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


Not Lua, but you could take a look at how it's handled in CodeCombat. Each text item is written separately for each language and they contain variable names or embedded code.
https://github.com/codecombat/codecombat/tree/master/app/locale

Example: "{person} taunts {enemy}." or "Good morning {player.name:capitalize()}!"
What characters you use for escaping is up to you.

I'm also pretty sure there already are libraries for doing this. There definitely were some libraries for i18n on the Löve wiki.
https://www.love2d.org/wiki/Category:Libraries

On Tue, Feb 23, 2016 at 5:15 PM, Scott Morgan <blumf@blueyonder.co.uk> wrote:
I'm in the middle of a project where my scripts might have to return
localised texts. Nothing too fancy just plain strings (i.e. no
formatting of results, time/date formats, etc.)

I think Lua's tables will be good enough to handle holding the data but
was wondering if anybody had any experience or insights into organising
the data.

Stuff like:
 * One big file with all translation, or separate files per language/region?
 * Pull in via require, or some hand rolled loader?
 * Use raw tables, meta-table object, or a function call to access the text?
 * ID the texts via a native language value, or some unique ID number?
 * Finding all locations of translated texts in code base to send off
for translation

Scott