Prado\PradoBase::localize PHP Method

localize() public static method

Localize a text to the locale/culture specified in the globalization handler.
See also: TTranslate::formatter()
See also: TTranslate::init()
public static localize ( $text, $parameters = [], $catalogue = null, $charset = null ) : string
return string localized text.
    public static function localize($text, $parameters = array(), $catalogue = null, $charset = null)
    {
        $app = Prado::getApplication()->getGlobalization(false);
        $params = array();
        foreach ($parameters as $key => $value) {
            $params['{' . $key . '}'] = $value;
        }
        //no translation handler provided
        if ($app === null || ($config = $app->getTranslationConfiguration()) === null) {
            return strtr($text, $params);
        }
        if ($catalogue === null) {
            $catalogue = isset($config['catalogue']) ? $config['catalogue'] : 'messages';
        }
        Translation::init($catalogue);
        //globalization charset
        $appCharset = $app === null ? '' : $app->getCharset();
        //default charset
        $defaultCharset = $app === null ? 'UTF-8' : $app->getDefaultCharset();
        //fall back
        if (empty($charset)) {
            $charset = $appCharset;
        }
        if (empty($charset)) {
            $charset = $defaultCharset;
        }
        return Translation::formatter($catalogue)->format($text, $params, $catalogue, $charset);
    }