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 ===

Revision as of 16:38, 21 June 2026

<> Lua API 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

Parameter Type Description
string String The string to translate.

Returns

string — The translated string, or the original string if no translation could be found.

Examples

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

Main Pages

Core Lua documentation entry points

Lua
Script Engine

Related Functions