diff --git a/_en/quality/translations.md b/_en/quality/translations.md index 37e63ad..ab183ea 100644 --- a/_en/quality/translations.md +++ b/_en/quality/translations.md @@ -40,7 +40,7 @@ see a different language. - [How does client-side translation work?](#how-does-client-side-translation-work) - - [Marked text](#marked-text) + - [Marked up text](#marked-up-text) - [Translation files](#translation-files) - [Format strings](#format-strings) - [Best practices and Common Falsehoods about Translation](#best-practices-and-common-falsehoods-about-translation) @@ -50,10 +50,13 @@ see a different language. ## How does client-side translation work? -### Marked text +### Marked up text -The server needs to tell clients how to translate text. This is done by marking -text as translatable using a translator function (`S()`), returned by +The server needs to tell clients how to translate text. This is done by placing +control characters in text, telling Minetest where and how to translate +text. This is referred to as marked up text, and will be discussed more later. + +To mark text as translatable, use a translator function (`S()`), obtained using `minetest.get_translator(textdomain)`: ```lua @@ -70,18 +73,19 @@ file, translations are separated into textdomains, with a file per textdomain per language. The textdomain should be the same as the mod name, as it helps avoid mod conflicts. -Marked text can be used in most places where human-readable text is accepted, +Marked up text can be used in most places where human-readable text is accepted, including formspecs, item def fields, infotext, and more. When including marked -text in formspecs, you need to escape the text using -`minetest.formspec_escape`. +text in formspecs, you need to escape the text using `minetest.formspec_escape`. -When the client encounters marked text, such as that passed to `description`, it -looks it up in the player's language's translation file. If a translation cannot -be found, it falls back to the English translation. +When the client encounters translatable text, such as that passed to +`description`, it looks it up in the player's language's translation file. If a +translation cannot be found, it falls back to the English translation. -Marked text contains the English source text, the textdomain, and any additional -arguments passed to `S()`. It's essentially a text encoding of the `S` call, -containing all the required information. +Translatable marked up text contains the English source text, the textdomain, +and any additional arguments passed to `S()`. It's essentially a text encoding +of the `S` call, containing all the required information. + +Another type of marked up text is that returned by `minetest.colorize`. {% include notice.html notice=page.marked_text_encoding %} @@ -111,6 +115,9 @@ This tool will look for `S(` in your Lua code, and automatically create a template that translators can use to translate into their language. It also handles updating the translation files when your source changes. +You should always put literal text (`"`) inside S rather than using a variable, +as it helps tools find translations. + ## Format strings @@ -157,7 +164,7 @@ S("Hello @1!", player_name) .. " " .. S("You have @1 new messages.", #msgs) Sometimes you need to know the translation of text on the server, for example, to sort or search text. You can use `get_player_information` to get a player's -lang,uage and `get_translated_string` to translate marked text. +language and `get_translated_string` to translate marked text. ```lua local list = { @@ -185,7 +192,7 @@ minetest.register_chatcommand("find", { The translation API allows making mods and games more accessible, but care is needed in order to use it correctly. -Minetest is continuously improving, and the translation API is likey to be +Minetest is continuously improving, and the translation API is likely to be extended in the future. For example, support for gettext translation files will allow common translator tools and platforms (like weblate) to be used, and there's likely to be support for pluralisation and gender added.