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
This commit is contained in:
Wuzzy 2024-12-14 16:59:29 +01:00 committed by GitHub
parent ac7406c8a1
commit ba63c1505a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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
```