Knights currently has a work-in-progress localization system. This means that, eventually, it will become possible to translate the game into different languages.
The system works by defining a set of localization "keys" which correspond to individual messages. For example, the key healing corresponds to the message "Healing" (in English). When the user drinks a healing potion, the Lua code calls kts.FlashMessage("healing"); the game then looks up healing in the file knights_data/client/localization_strings.txt, finds the corresponding message "Healing", and displays that message on-screen.
In theory, to support other languages, all we would need to do is substitute a different localization_strings.txt file. For example, in German, healing might map to "Heilung".
In practice, not all of the in-game messages have been moved over to the localization system yet, so only a partial translation would be possible right now. Also, the game doesn't provide any kind of UI for the user to select a language. Finally, the game code only partially supports Unicode (e.g. a lot of the UI can only handle Latin-1 strings at this time), so languages like Russian or Greek would be impossible to support currently. It is hoped that these issues will be resolved in the future.
One feature of the system is that localization messages can include parameters (numbered from zero). For example, the message for desc_escape_gems is "Your mission is to escape via {0} with {1} out of {2} gems.". Here, {0}, {1} and {2} are parameters. Parameters will be substituted at runtime with various things like other localized strings, player names, or raw numbers. For example, in this case, {0} might map to the message "your entry point" (coming from the localization key desc_exit_same), and {1} and {2} might map to the numbers 3 and 4 respectively, to make the message "Your mission is to escape via your entry point with 3 out of 4 gems.".
Another feature of the system is that messages can have separate variants for singular and plural forms. In English these two forms are called one and other, respectively (different rules might be defined for different languages, and some languages may have more than two forms). For example, the localization strings file defines both retrieve_gem[one], which maps to "Retrieve {0} gem", and retrieve_gem[other], which maps to "Retrieve {0} gems".
Finally, some messages support lists of parameters using a special ... syntax. Since this is a fairly rare special case, it is not described fully here, but see the message is_winner in localization_strings.txt for an example.
In Lua, there are many functions which take a localized message as a parameter: e.g. kts.FlashMessage and kts.PrintLoc.
For the localization message parameter, the Lua code may pass either of the following things:
key (required), which gives the localization key. params (optional), which is a Lua array table containing the message parameters. Each parameter can be either a string (which indicates another localization key) or an integer. Note that the indices in the Lua table begin from 1, but the parameter numbers in the message (like {0}) begin from 0. plural (optional), which allows different message forms to be used for singular and plural. If this is present it must be set to a non-negative integer. In English, if plural is 1, then the suffix [one] will be appended to the key, otherwise, [other] will be appended. (Other rules may be applied for other languages.) Examples:
kts.PrintLoc("dispel_magic") would print "Dispel Magic". kts.PrintLoc({key="desc_escape", params={"desc_exit_guarded"}}) would print "Your mission is to escape via the guarded exit." kts.PrintLoc({key="desc_retrieve_gems", params={"desc_book", "desc_exit_same", 4, 6}}) would print "You must retrieve the book and escape via your entry point with 4 out of 6 gems." kts.PrintLoc({key="gem_required", params={4}, plural=4}) would print "4 Gems Required". This is because plural is 4, so [other] is appended to the key (i.e., the key looked up in localization_strings.txt is not gem_required, but gem_required[other]). kts.PrintLoc({key="gem_required", params={4}}) (without a plural value) would print "Missing string [gem_required]" (i.e. this would be an error). This is because no plural parameter has been supplied, so the game tries to look up gem_required directly, instead of either gem_required[one] or gem_required[other]. But gem_required is not defined in localization_strings.txt, hence the "missing string" error. knights_data/client/localization_strings.txt, where the localization keys (and corresponding messages) are defined.