Home  Contents

tr.load

Tr Core4 Lua Commands

SYNOPSIS

tr.load(filename[, filename[, ...]])

DESCRIPTION

Loads one or more files containing translations. If an error is encountered on reading a file, reading continues until 20 errors are seen or all files have been processed.

The last filename is processed first, then iterating backwards over the list. Thus, translations in earlier files have priority over later files.

The file format is simple CSV, e.g:

1000,"Please wait" 2000,"Welcome, %1" 3000,"Access denied"

For non-ASCII characters, UTF8 encoding can be used or the characters can be encoded using escape sequences:

\n Newline
\xNN Hexadecimal single byte character
\uNNNN 16-bit hexadecimal Unicode codepoint, will be converted to UTF-8

RETURN VALUE

Returns a lookup table with all translations found as first and a status as second value. The status is nil if no error was found, or a string of up to 20 lines describing what errors where found in the file(s).

NOTES

Excel needs a Unicode Byte-Order Mark at the beginning of the file to properly open UTF-8 encoded files. The Byte-Order Mark is the byte sequence 0xEF 0xBB 0xBF. The mark is ignored when loaded with tr.load().

EXAMPLE

tr[1] = tr.load("path/to/some/file.csv")

SEE ALSO