Kategorie: Script / Strings
Ab Engineversion: 8.0 OC


Returns a string corresponding to the user's selected language. For string_data, the expected format is { Function="Translate", DE="Hallo, Welt", US="Hello, World"}. If no matching entry is found or it is nil, then another language string is returned as a fallback.


string GetTranslatedString(any string_data);


Either a string or a proplist containing multiple translations of a string. If a string or nil is passed, the parameter is returned directly. If a proplist is passed, the value corresponding to the selected language (or a fallback) is returned.


Log(GetTranslatedString({ Function="Translate", DE="Dies ist ein Test.", US="This is a test."}));
Logs either "Dies ist ein Test." or "This is a test." depending on the player's language setting.
local inscription = "";

// Players can read the sign via the interaction bar.
public func IsInteractable() { return true; }

// Called on player interaction.
public func Interact(object clonk)
	if (!clonk) return false;
	Dialogue->MessageBox(GetTranslatedString(inscription), clonk, this, clonk->GetController(), true);
	return true;

public func SetInscription(to_text)
	inscription = to_text ?? "";
	return true;

public func Definition(def)
	// Inscription props
	if (!def.EditorProps) def.EditorProps = {};
	def.EditorProps.inscription = { Name="Inscription", Type="string", Set="SetInscription", Save="Inscription", Translatable=true };
Code for a signpost. The string editor property with setting Translatable=true provides a translation proplist in the correct format automatically.
Siehe auch: Translate
Sven2, 2017-05