Netson\L4gettext\L4gettext::__construct PHP 메소드

__construct() 공개 메소드

constructor method accepts an optional $locale, otherwise the default will be used
public __construct ( )
    public function __construct()
    {
        // check if a locale is present in the session
        // otherwise use default
        $session_locale = Session::get('l4gettext_locale', null);
        $locale = is_null($session_locale) ? Config::get("l4gettext::config.default_locale") : $session_locale;
        Session::forget('l4gettext_locale');
        // check if an encoding is present in the session
        $session_encoding = Session::get('l4gettext_encoding', null);
        $encoding = is_null($session_encoding) ? Config::get("l4gettext::config.default_encoding") : $session_encoding;
        Session::forget('l4gettext_encoding');
        // set the encoding and locale
        $this->setEncoding($encoding)->setLocale($locale);
        // determine and set textdomain
        $textdomain = Config::get("l4gettext::config.textdomain");
        $path = Config::get("l4gettext::config.path_to_mo");
        $this->setTextDomain($textdomain, $path);
    }