Difference between revisions of "Lua:translate"

From Cheat Engine
Jump to navigation Jump to search
(Related Functions)
m
 
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
'''function''' translate(''String'') ''':''' string
+
{{CodeBox|'''function''' translate(''string'') ''':''' string}}
  
Returns a translation of the string. Returns the same string if it can't be found.
+
Returns a translation of the given string.
  
=== Function Parameters ===
+
If no translation can be found, this function returns the original string unchanged.
  
{|width="85%" cellpadding="10%" cellpadding="5%" cellspacing="0" border="0"
+
===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
|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>
  
== See also ==
+
{{LuaSeeAlso}}
* [[Lua]]
 
* [[Help_File:Script engine|Script engine]]
 
  
 
=== 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

Related Functions[edit]