Gdn_Locale::translate PHP Method

translate() public method

Translates a code into the selected locale's definition.
public translate ( string $Code, string $Default = false ) : string
$Code string The code related to the language-specific definition. Codes that begin with an '@' symbol are treated as literals and not translated.
$Default string The default value to be displayed if the translation code is not found.
return string
    public function translate($Code, $Default = false)
    {
        if ($Default === false) {
            $Default = $Code;
        }
        // Codes that begin with @ are considered literals.
        if (substr_compare('@', $Code, 0, 1) == 0) {
            return substr($Code, 1);
        }
        $Translation = $this->LocaleContainer->get($Code, $Default);
        // If developer mode is on, and this translation returned the default value,
        // remember it and save it to the developer locale.
        if ($this->DeveloperMode && $Translation == $Default) {
            $DevKnows = $this->DeveloperContainer->get($Code, false);
            if ($DevKnows === false) {
                $this->DeveloperContainer->saveToConfig($Code, $Default);
            }
        }
        $this->EventArguments['Code'] = $Code;
        $this->EventArguments['Default'] = $Default;
        $this->fireEvent('BeforeTranslate');
        return $Translation;
    }