Skip to content

Commit

Permalink
Docs: Change varname for translation from NS to PS
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuzzy2 committed Nov 24, 2024
1 parent 4faa16f commit 9ef997c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions doc/lua_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4183,14 +4183,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, ...)
```

Expand Down Expand Up @@ -4224,7 +4224,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))
Expand All @@ -4233,7 +4233,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))
Expand Down Expand Up @@ -4280,7 +4280,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
```

Expand Down

0 comments on commit 9ef997c

Please sign in to comment.