src/php/main/Eix/Core/Application.php
public function setLocale($locale = null)
    {
        if (class_exists('\Locale')) {
            $this->locale = \Locale::lookup(
                $this->getAvailableLocales(),
                $locale,
                true,
                $this->getSettings()->locale->default
            );
        }

        if (empty($this->locale)) {
            $this->locale = $this->getSettings()->locale->default;
        }

        // Set up locale environment for gettext.
        bindtextdomain(self::TEXT_DOMAIN_NAME, self::TEXT_DOMAIN_LOCATION);
        bind_textdomain_codeset(self::TEXT_DOMAIN_NAME, 'UTF-8');
        textdomain(self::TEXT_DOMAIN_NAME);
        putenv('LANG=' . $this->locale);
        putenv('LC_MESSAGES=' . $this->locale);
        $locale = setlocale(LC_MESSAGES, $this->locale);

        Logger::get()->info(sprintf('Locale is now %s [%s] (domain "%s" at %s)',
            $locale,
            $this->locale,
            self::TEXT_DOMAIN_NAME,
            realpath(self::TEXT_DOMAIN_LOCATION)
        ));
    }
public function setLocale($locale = null)
    {
        if (class_exists('\Locale')) {
            $this->locale = \Locale::lookup(
                $this->getAvailableLocales(),
                $locale,
                true,
                $this->getSettings()->locale->default
            );
        }

        if (empty($this->locale)) {
            $this->locale = $this->getSettings()->locale->default;
        }

        // Set up locale environment for gettext.
        bindtextdomain(self::TEXT_DOMAIN_NAME, self::TEXT_DOMAIN_LOCATION);
        bind_textdomain_codeset(self::TEXT_DOMAIN_NAME, 'UTF-8');
        textdomain(self::TEXT_DOMAIN_NAME);
        putenv('LANG=' . $this->locale);
        putenv('LC_MESSAGES=' . $this->locale);
        $locale = setlocale(LC_MESSAGES, $this->locale);

        Logger::get()->info(sprintf('Locale is now %s [%s] (domain "%s" at %s)',
            $locale,
            $this->locale,
            self::TEXT_DOMAIN_NAME,
            realpath(self::TEXT_DOMAIN_LOCATION)
        ));
    }
public function setLocale ( $ locale = null ) { if ( class_exists ( '\Locale' ) ) { $ this -> locale = \ Locale :: lookup ( $ this -> getAvailableLocales ( ) , $ locale , true , $ this -> getSettings ( ) -> locale -> default ) ; } if ( empty ( $ this -> locale ) ) { $ this -> locale = $ this -> getSettings ( ) -> locale -> default ; } // Set up locale environment for gettext. bindtextdomain ( self :: TEXT_DOMAIN_NAME , self :: TEXT_DOMAIN_LOCATION ) ; bind_textdomain_codeset ( self :: TEXT_DOMAIN_NAME , 'UTF-8' ) ; textdomain ( self :: TEXT_DOMAIN_NAME ) ; putenv ( 'LANG=' . $ this -> locale ) ; putenv ( 'LC_MESSAGES=' . $ this -> locale ) ; $ locale = setlocale ( LC_MESSAGES , $ this -> locale ) ; Logger :: get ( ) -> info ( sprintf ( 'Locale is now %s [%s] (domain "%s" at %s)' , $ locale , $ this -> locale , self :: TEXT_DOMAIN_NAME , realpath ( self :: TEXT_DOMAIN_LOCATION ) ) ) ; }
Sets the locale of the application, if this locale is available.
@param string $locale the new locale.
Sets the locale of the application if this locale is available .