Difference between revisions of "Lua:translate"
Jump to navigation
Jump to search
(→Related Functions) |
m |
||
| Line 1: | Line 1: | ||
[[Category:Lua]] | [[Category:Lua]] | ||
| − | '''function''' translate('' | + | {{CodeBox|'''function''' translate(''string'') ''':''' string}} |
| − | Returns a translation of the string | + | Returns a translation of the given string. |
| − | + | If no translation can be found, this function returns the original string unchanged. | |
| − | {|width="85%" cellpadding="10 | + | ===Function Parameters=== |
| + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" | ||
!align="left"|Parameter | !align="left"|Parameter | ||
!align="left"|Type | !align="left"|Type | ||
!style="width: 80%;background-color:white;" align="left"|Description | !style="width: 80%;background-color:white;" align="left"|Description | ||
|- | |- | ||
| + | |string | ||
|String | |String | ||
| − | + | |The string to translate. | |
| − | |The string to translate | ||
|} | |} | ||
| + | ===Returns=== | ||
| + | string — The translated string, or the original string if no translation could be found. | ||
| + | |||
| + | ===Examples=== | ||
| + | <pre> | ||
| + | local text = translate("Health") | ||
| + | |||
| + | print(text) | ||
| + | </pre> | ||
| + | |||
| + | <pre> | ||
| + | local originalText = "Mana" | ||
| + | local translatedText = translate(originalText) | ||
| + | |||
| + | if translatedText == originalText then | ||
| + | print("No translation found") | ||
| + | else | ||
| + | print("Translation: " .. translatedText) | ||
| + | end | ||
| + | </pre> | ||
| − | + | {{LuaSeeAlso}} | |
| − | |||
| − | |||
=== Related Functions === | === Related Functions === | ||
Latest revision as of 16:38, 21 June 2026
| <> Function function translate(string) : string |
Returns a translation of the given string.
If no translation can be found, this function returns the original string unchanged.
Function Parameters[edit]
| Parameter | Type | Description |
|---|---|---|
| string | String | The string to translate. |
Returns[edit]
string — The translated string, or the original string if no translation could be found.
Examples[edit]
local text = translate("Health")
print(text)
local originalText = "Mana"
local translatedText = translate(originalText)
if translatedText == originalText then
print("No translation found")
else
print("Translation: " .. translatedText)
end
See also[edit]
| Lua |
| Script Engine |