Skip to content
This repository has been archived by the owner on Dec 2, 2017. It is now read-only.

AIIXForm and i18n

ailixter edited this page Mar 5, 2016 · 8 revisions
class Custom {

    static function translate ($text, $context) {
        return isset(self::$dictionary[$text]) ?
            self::$dictionary[$text] : $text;
    }

    static $dictionary = array(
        "Labeled Control"   => "Элемент с меткой",
        "Complex"           => "Сложный",
        "labeled5"          => "По-русски",
        "abcd"              => "АБВГ"
    );
}

\AIIX\Form::setTranslator("Custom::translate");

echo \AIIX\Form::label('labeled1');
echo \AIIX\Form::label('labeled3');
echo \AIIX\Form::label('labeled5');
<label for="labeled1">Элемент с меткой</label>
<label class="test" for="labeled3">Сложный</label>
<label for="labeled5">По-русски</label>
echo \AIIX\Form::translate('abcd');
echo \AIIX\Form::translate('xyz');
АБВГ
xyz
\AIIX\Form::setTranslator(false);
<label for="labeled5">labeled5</label>