Translate component texts and your text inputs

Interface Mesour\Components\Localization\ITranslator

Method Parameters Returns Description
translate string $message, int $count = NULL string Called if word is for translate

Create your translator

For example StaticTranslator

Info Can create database, gettext translator or whatever
class StaticTranslator implements Mesour\Components\Localization\ITranslator
    private $translates = [
        'example text' => 'translated text',
        'example second' => 'translated second',
        // etc

    public function translate($message, $count = NULL) {
        if(isset($this->translates[$message])) {
            return $this->translates[$message];
        return $message;

Set for specific component for example Button

/** @var Mesour\UI\Button $button */
$button->setTranslator(new StaticTranslator);

Set for Mesour\UI\Application

Info You can set translator for Mesour\UI\Application and it will be used for all sub components
/** @var Mesour\UI\Application $application */
$application->setTranslator(new StaticTranslator);