Home  Contents

Contextual Mode

Tr Core4 Lua Commands

DESCRIPTION

In contextual mode, translation support is handled in several steps:

  1. Use tr() for all user visible text.
  2. Produce translation source files from your Lua source code.
  3. Translate the text using Qt Linguist.
  4. In you lua code, load the translations using tr:installTranslator().

Use tr() for all user visible text.

Text that needs to be translated is simply wrapped into a call to tr(), like this:

hello.lua:

print(tr("Hello World"))

At runtime, the tr() looks up the text in a loaded translation table and returns the translation if found. When a translation is missing, the original text is returned. In that way, even a few missing translations won't render the application useless, as long as the user can understand the untranslated text.

Produce translation source files from your Lua source code.

Translatable text needs to be extracted from the Lua source code and written into a translation source (.ts) file. This is handled by Core4Manager (TODO). For each language, you need one translation source file.

Translate the text using Qt Linguist.

Using the free tool Qt Linguist, a translator can work on the translation without needing knowledge about computer programming.

Load the translations using tr:installTranslator()

Core4Manager(TODO) compiles the translation source files into .qm files, which are included into the final application. During runtime, the translation data is loaded using tr:installTranslator().

SEE ALSO