Skip to content

Commit

Permalink
Fix docs after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Ekdohibs committed Jul 24, 2023
1 parent 70ace62 commit 0819a09
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
23 changes: 17 additions & 6 deletions doc/lua_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3975,12 +3975,17 @@ Helper functions
* `wear`: Amount of wear the item starts with (default: 0)




Translations
============

Texts can be translated client-side with the help of `minetest.translate` and
translation files.

Consider using the tool [update_translations](https://github.com/minetest-tools/update_translations)
to generate and update translation files automatically from the Lua source.

Translating a string
--------------------

Expand All @@ -3995,8 +4000,10 @@ Two functions are provided to translate strings: `minetest.translate` and
It is intended to be used in the following way, so that it avoids verbose
repetitions of `minetest.translate`:

local S, NS = minetest.get_translator(textdomain)
S(str, ...)
```lua
local S, NS = minetest.get_translator(textdomain)
S(str, ...)
```

As an extra commodity, if `textdomain` is nil, it is assumed to be "" instead.

Expand All @@ -4015,15 +4022,19 @@ Two functions are provided to translate strings: `minetest.translate` and
For instance, suppose we want to translate "@1 Wool" with "@1" being replaced
by the translation of "Red". We can do the following:

local S, NS = minetest.get_translator()
S("@1 Wool", S("Red"))
```lua
local S, NS = minetest.get_translator()
S("@1 Wool", S("Red"))
```

This will be displayed as "Red Wool" on old clients and on clients that do
not have localization enabled. However, if we have for instance a translation
file named `wool.fr.tr` containing the following:

@1 Wool=Laine @1
Red=Rouge
```
@1 Wool=Laine @1
Red=Rouge
```

this will be displayed as "Laine Rouge" on clients with a French locale.

Expand Down
3 changes: 3 additions & 0 deletions doc/lua_api.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Moved to lua_api.md

URL: https://github.com/minetest/minetest/blob/master/doc/lua_api.md

0 comments on commit 0819a09

Please sign in to comment.