public function translate($args, array $languages = null, $array_support = false, $html_out = false)
    {
        if (\is_array($args)) {
            $lookup = array_shift($args);
        } else {
            $lookup = $args;
            $args = [];
        }

        if ($this->config->get('system.languages.translations', true)) {
            if ($this->enabled() && $lookup) {
                if (empty($languages)) {
                    if ($this->config->get('system.languages.translations_fallback', true)) {
                        $languages = $this->getFallbackLanguages();
                    } else {
                        $languages = (array)$this->getLanguage();
                    }
                }
            } else {
                $languages = ['en'];
            }

            foreach ((array)$languages as $lang) {
                $translation = $this->getTranslation($lang, $lookup, $array_support);

                if ($translation) {
                    if (\count($args) >= 1) {
                        return vsprintf($translation, $args);
                    }

                    return $translation;
                }
            }
        }

        if ($html_out) {
            return '<span class="untranslated">' . $lookup . '</span>';
        }

        return $lookup;
    }
public function translate($args, array $languages = null, $array_support = false, $html_out = false)
    {
        if (\is_array($args)) {
            $lookup = array_shift($args);
        } else {
            $lookup = $args;
            $args = [];
        }

        if ($this->config->get('system.languages.translations', true)) {
            if ($this->enabled() && $lookup) {
                if (empty($languages)) {
                    if ($this->config->get('system.languages.translations_fallback', true)) {
                        $languages = $this->getFallbackLanguages();
                    } else {
                        $languages = (array)$this->getLanguage();
                    }
                }
            } else {
                $languages = ['en'];
            }

            foreach ((array)$languages as $lang) {
                $translation = $this->getTranslation($lang, $lookup, $array_support);

                if ($translation) {
                    if (\count($args) >= 1) {
                        return vsprintf($translation, $args);
                    }

                    return $translation;
                }
            }
        }

        if ($html_out) {
            return '<span class="untranslated">' . $lookup . '</span>';
        }

        return $lookup;
    }
public function translate ( $ args , array $ languages = null , $ array_support = false , $ html_out = false ) { if ( \ is_array ( $ args ) ) { $ lookup = array_shift ( $ args ) ; } else { $ lookup = $ args ; $ args = [ ] ; } if ( $ this -> config -> get ( 'system.languages.translations' , true ) ) { if ( $ this -> enabled ( ) && $ lookup ) { if ( empty ( $ languages ) ) { if ( $ this -> config -> get ( 'system.languages.translations_fallback' , true ) ) { $ languages = $ this -> getFallbackLanguages ( ) ; } else { $ languages = ( array ) $ this -> getLanguage ( ) ; } } } else { $ languages = [ 'en' ] ; } foreach ( ( array ) $ languages as $ lang ) { $ translation = $ this -> getTranslation ( $ lang , $ lookup , $ array_support ) ; if ( $ translation ) { if ( \ count ( $ args ) >= 1 ) { return vsprintf ( $ translation , $ args ) ; } return $ translation ; } } } if ( $ html_out ) { return '<span class="untranslated">' . $ lookup . '</span>' ; } return $ lookup ; }
Translate a key and possibly arguments into a string using current lang and fallbacks

@param string|array $args      The first argument is the lookup key value
Other arguments can be passed and replaced in the translation with sprintf syntax
@param array $languages
@param bool  $array_support
@param bool  $html_out

@return string
Translate a key and possibly arguments into a string using current lang and fallbacks