ManaPHP\I18n\Translation::__construct PHP Method

__construct() public method

Translation constructor.
public __construct ( array $options = [] )
$options array
    public function __construct($options = [])
    {
        if (isset($options['files'])) {
            $files = $options['files'];
        } else {
            $files = ['@messages/:language/' . 'Module.php', '@messages/:language/' . $this->dispatcher->getControllerName() . '.php'];
        }
        if (isset($options['language'])) {
            $this->_language = preg_replace('#\\s*#', '', $options['language']);
        } else {
            $this->_language = 'en';
        }
        $languages = array_reverse(explode(',', $this->_language));
        /** @noinspection ForeachSourceInspection */
        foreach ($files as $file) {
            foreach ($languages as $language) {
                $f = strtr($file, [':language' => $language]);
                if ($this->filesystem->fileExists($f)) {
                    /** @noinspection PhpIncludeInspection */
                    $messages = (require $this->alias->resolve($f));
                    /** @noinspection SlowArrayOperationsInLoopInspection */
                    $this->_messages = array_merge($this->_messages, $messages);
                    $this->_files[] = $f;
                }
            }
        }
    }