Difference between revisions of "Lua:translate"
Jump to navigation
Jump to search
m |
m (Syntax Highlighting.) |
||
| Line 21: | Line 21: | ||
===Examples=== | ===Examples=== | ||
| − | < | + | <syntaxhighlight lang="lua" line> |
local text = translate("Health") | local text = translate("Health") | ||
print(text) | print(text) | ||
| − | </ | + | </syntaxhighlight> |
| − | < | + | <syntaxhighlight lang="lua" line> |
local originalText = "Mana" | local originalText = "Mana" | ||
local translatedText = translate(originalText) | local translatedText = translate(originalText) | ||
| Line 36: | Line 36: | ||
print("Translation: " .. translatedText) | print("Translation: " .. translatedText) | ||
end | end | ||
| − | </ | + | </syntaxhighlight> |
{{LuaSeeAlso}} | {{LuaSeeAlso}} | ||
| − | + | {{Strings}} | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Latest revision as of 19:22, 25 June 2026
<> Reference
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]
1 local text = translate("Health")
2
3 print(text)
1 local originalText = "Mana"
2 local translatedText = translate(originalText)
3
4 if translatedText == originalText then
5 print("No translation found")
6 else
7 print("Translation: " .. translatedText)
8 end
See Also[edit]
Main Pages
String and Encoding Related Lua Functions
Translation and Encoding
String Memory Access
Byte Table Conversions