61 lines
2.5 KiB
Lua
61 lines
2.5 KiB
Lua
---Version: 5.18
|
|
---@meta
|
|
|
|
--- Translations ---
|
|
|
|
---Is a simple wrapper around `core.translate` and `core.translate_n`.
|
|
---
|
|
---After `local S, PS = core.get_translator(textdomain)`,
|
|
---we have `S(str, ...)` equivalent to `core.translate(textdomain, str, ...)`, and
|
|
---`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, PS = core.get_translator(textdomain)
|
|
--- S(str, ...)
|
|
---```
|
|
---
|
|
---As an extra commodity, if `textdomain` is nil, it is assumed to be `""` instead.
|
|
---@param textdomain string?
|
|
---@return fun(str:string, ...):string, fun(str:string, ...):string
|
|
function core.get_translator(textdomain) end
|
|
|
|
---Translates the string `str` with the given `textdomain` for disambiguation.
|
|
---
|
|
---The textdomain must match the textdomain specified in the translation file
|
|
---in order to get the string translated. This can be used so that a string
|
|
---is translated differently in different contexts. It is advised to use
|
|
---the name of the mod as textdomain whenever possible, to avoid clashes with other mods.
|
|
---
|
|
---This function must be given an amount of arguments equal to the amount of arguments
|
|
---the translated string expects. Arguments are literal strings -- they will not be translated.
|
|
---@param textdomain string
|
|
---@param str string
|
|
---@param ... string
|
|
---@return string
|
|
function core.translate(textdomain, str, ...) end
|
|
|
|
---Translates the string `str` with the given `textdomain` for disambiguation.
|
|
---
|
|
---The value of `n`, which must be a nonnegative integer,
|
|
---is used to decide whether to use the singular or the plural version of the string.
|
|
---
|
|
---Depending on the locale of the client, the choice between singular and plural
|
|
---might be more complicated, but the choice will be done automatically using the value of `n`.
|
|
---@param textdomain string
|
|
---@param str string
|
|
---@param str_plural string
|
|
---@param n string
|
|
---@param ... string
|
|
---@return string
|
|
function core.translate_n(textdomain, str, str_plural, n, ...) end
|
|
|
|
---Resolves translations in the given string just like the client would,
|
|
---using the translation files for `lang_code`. For this to have any effect,
|
|
---the string needs to contain translation markup,
|
|
---e.g. `core.get_translated_string("fr", S("Hello"))`.
|
|
---@param lang_code string
|
|
---@param str string
|
|
---@return string
|
|
function core.get_translated_string(lang_code, str) end
|