From ba63c1505ad4cda3d959ed0402c9c4c9771ba7f9 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 14 Dec 2024 16:59:29 +0100 Subject: [PATCH] Docs: Change translation example from `NS` to `PS` (#15476) The currently established convention uses `NS` for "translation no-ops", i.e., it will be collected by a string-collecting utility but not be translated by Luanti at this place. We don't want to mislead modders with this example into using `NS` for plural forms instead, breaking with the established convention and making use of automated tools harder. See also: https://github.com/minetest/modtools/pull/11 --- doc/lua_api.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/lua_api.md b/doc/lua_api.md index c4c74d884..7fe464a30 100644 --- a/doc/lua_api.md +++ b/doc/lua_api.md @@ -4190,14 +4190,14 @@ Two functions are provided to translate strings: `core.translate` and * `core.get_translator(textdomain)` is a simple wrapper around `core.translate` and `core.translate_n`. - After `local S, NS = core.get_translator(textdomain)`, we have + After `local S, PS = core.get_translator(textdomain)`, we have `S(str, ...)` equivalent to `core.translate(textdomain, str, ...)`, and - `NS(str, str_plural, n, ...)` to `core.translate_n(textdomain, str, str_plural, n, ...)`. + `PS(str, str_plural, n, ...)` to `core.translate_n(textdomain, str, str_plural, n, ...)`. It is intended to be used in the following way, so that it avoids verbose repetitions of `core.translate`: ```lua - local S, NS = core.get_translator(textdomain) + local S, PS = core.get_translator(textdomain) S(str, ...) ``` @@ -4231,7 +4231,7 @@ command that shows the amount of time since the player joined. We can do the following: ```lua -local S, NS = core.get_translator("hello") +local S, PS = core.get_translator("hello") core.register_on_joinplayer(function(player) local name = player:get_player_name() core.chat_send_player(name, S("Hello @1, how are you today?", name)) @@ -4240,7 +4240,7 @@ core.register_chatcommand("playtime", { func = function(name) local last_login = core.get_auth_handler().get_auth(name).last_login local playtime = math.floor((last_login-os.time())/60) - return true, NS( + return true, PS( "You have been playing for @1 minute.", "You have been playing for @1 minutes.", minutes, tostring(minutes)) @@ -4287,7 +4287,7 @@ After creating the `locale` directory, a translation template for the above example using the following command: ```sh -xgettext -L lua -kS -kNS:1,2 -kcore.translate:1c,2 -kcore.translate_n:1c,2,3 \ +xgettext -L lua -kS -kPS:1,2 -kcore.translate:1c,2 -kcore.translate_n:1c,2,3 \ -d hello -o locale/hello.pot *.lua ```