common\Language::trans PHP Method

trans() public method

public trans ( $id, array $parameters = [], $domain = null, $locale = null )
$parameters array
    public function trans($id, array $parameters = [], $domain = null, $locale = null)
    {
        $possibleActions = ['lbl', 'err', 'msg'];
        if (self::get() === FrontendLanguage::class) {
            $possibleActions[] = 'act';
        }
        if (!preg_match('/(' . implode('|', $possibleActions) . ')./', $id)) {
            return parent::trans($id, $parameters, $domain, $locale);
        }
        if (!strpos($id, '.')) {
            return parent::trans($id, $parameters, $domain, $locale);
        }
        list($action, $string) = explode('.', $id, 2);
        if (!in_array($action, $possibleActions)) {
            return parent::trans($id, $parameters, $domain, $locale);
        }
        $translatedString = self::$action($string);
        // we couldn't translate it, let the parent have a go
        if (preg_match('/\\{\\$' . $action . '.*' . $string . '\\}/', $translatedString)) {
            $parentTranslatedString = parent::trans($id, $parameters, $domain, $locale);
            // If the parent couldn't translate return our default
            if ($id === $parentTranslatedString) {
                return $translatedString;
            }
            return $parentTranslatedString;
        }
        return $translatedString;
    }