What can we improve?

Documentation

(Edit)

Translate

Requires: IP-Symcon >= 4.3

string Translate (string $Text)

Parameters

Text Text to be translated

Returns

Translated text

Description

Translates the string Text using the selected system language and locale.json.

If no locale.json is available or the string cannot be found in locale.json, the original text is returned.

Example

//module.php
[...]
if (!IPS_VariableProfileExists("IPS.Shutter")) {
    IPS_CreateVariableProfile("IPS.Shutter", 0);
    IPS_SetVariableProfileIcon("IPS.Shutter", "IPS");
    IPS_SetVariableProfileAssociation("IPS.Shutter", 0, $this->Translate("Stopped"), "", 0x00FF00);
    IPS_SetVariableProfileAssociation("IPS.Shutter", 1, $this->Translate("Moving"), "", 0xFF0000);
}
[...]
$this->RegisterVariableBoolean("Switch",  $this->Translate("Switch"), "~Switch", 0);
[...]
$label = sprintf($this->Translate("The current time is %s"), date("d.m.y H:i"));
[...]
 
//locale.json
{
    "translations": {
        "de": {
            "Stopped": "Gestoppt",
            "Moving": "In Bewegung",
            "Switch": "Schalter",
            "The current time is %s": "Die aktuelle Zeit ist %s"
        }
    }
}
Deutsche Webseite verfügbar
Go to cart
Any questions?