setLocale
NOTE: We do NOT set LC_ALL because it causes "n tilde"
chars to be not json encodable after they have been strtolower'd

@param string|null $locale

@return void
334704
public function setLocale(
        $locale = null
    ) {
        if (empty($locale)) {
            $locale = $this->getDefaultLocale();
        }

        if (empty($locale)) {
            // @todo warning or error
            return;
        }

        /* Conversion for Ubuntu and Mac local settings. */
        if (!setlocale(LC_MONETARY, $locale . '.utf8')) {
            if (!setlocale(LC_MONETARY, $locale . '.UTF-8')) {
                setlocale(LC_MONETARY, 'en_US.UTF-8');
            }
        }

        /* Conversion for Ubuntu and Mac local settings. */
        if (!setlocale(LC_NUMERIC, $locale . '.utf8')) {
            if (!setlocale(LC_NUMERIC, $locale . '.UTF-8')) {
                setlocale(LC_NUMERIC, 'en_US.UTF-8');
            }
        }

        /* Conversion for Ubuntu and Mac local settings. */
        if (!setlocale(LC_TIME, $locale . '.utf8')) {
            if (!setlocale(LC_TIME, $locale . '.UTF-8')) {
                setlocale(LC_TIME, 'en_US.UTF-8');
            }
        }

        \Locale::setDefault($locale);
    }
941920
public function setLocale($locale = null, $remember = false)
    {
        $this->_locale->setLocale($locale);
        $t = $this->getTranslator();
        if ($t->isAvailable($this->_locale))
            $t->setLocale($this->_locale);
        if ($remember) $this->_session->locale = $this->_locale->toString();
    }
402149
public function resetForLocale(LocaleEntity $locale)
    {
        $this->createQueryBuilder('t')
            ->delete()
            ->where('t.locale = :locale')->setParameter('locale', $locale)
            ->getQuery()->execute();
    }
993847
public static void setLocale(Locale locale) {
        if (RepositoryUtils.locale == null) {
            RepositoryUtils.locale = locale;
        } else {
            if (RepositoryUtils.locale != locale) {
                RepositoryUtils.locale = locale;
                messages = null;
                installMessages = null;
            }
        }
    }
698956
public function setLocale($locale = null)
    {
        if ($locale === null) {
            $this->_locale = null;
            return $this;
        }

        include_once 'Zend/Locale.php';
        if (!Zend_Locale::isLocale($locale, true)) {
            if (!Zend_Locale::isLocale($locale, false)) {
                include_once 'Zend/Validate/Exception.php';
                throw new Zend_Validate_Exception("The locale '$locale' is no known locale");
            }

            $locale = new Zend_Locale($locale);
        }

        $this->_locale = (string) $locale;
        return $this;
    }
60018
public function setLocale($locale = null)
    {
        if (empty($locale) || ! is_string($locale)) {
            // If the locale has not been passed through the function
            // it tries to get it from the first segment of the url
            $locale = $this->request()->segment(1);
        }

        if ($this->isSupportedLocale($locale)) {
            $this->setCurrentLocale($locale);
        }
        else {
            // if the first segment/locale passed is not valid the system would ask which locale have to take
            // it could be taken by the browser depending on your configuration
            $locale = null;

            $this->getCurrentOrDefaultLocale();
        }

        $this->app->setLocale($this->getCurrentLocale());
        $this->updateRegional();

        return $locale;
    }
467334
public function setLocale($locale) {
		$this->locale          = trim($locale);
		$this->primaryLanguage = IntlLocale::getPrimaryLanguage($this->locale);
	}
683336
protected function initLocale($locale)
    {
        $file = $this->localeDir . '/' . $locale . '.php';
        if (file_exists($file)) {
            $data = include $file;

            if (!is_array($data)) {
                $data = [];
            }
        } else {
            $data = [];
        }

        if (!isset($data['pluralForm']) || !is_callable($data['pluralForm'])) {
            $data['pluralForm'] = null;
        }
        if (!isset($data['texts'])) {
            $data['texts'] = [];
        }

        $this->data[$locale] = $data;
    }
241283
public function setLocale($locale)
    {
        if (!is_string($locale) || empty($locale)) {
            throw new \InvalidArgumentException('Locale must be an IETF language tag.');
        }

        // Set the Locale on Fixer that needs it
        foreach ($this->_rules as $rule) {
            if ($rule instanceof LocaleAwareFixerInterface) {
                $rule->setLocale($locale);
            }
        }

        $this->locale = $locale;
    }
1159680
public function setAppLocale($locale = null, $session = true)
    {
        $locale = $locale ?: $this->session->get('_locale', null);

        if ($locale)
        {
            $this->app->setLocale($locale);

            if ($session)
            {
                $this->session->put('_locale', $locale);
            }

            $this->setTimeLocale($locale);
        }
    }
1208693
public function setLocale($locale)
    {
        $locale = preg_replace_callback('/[-_]([a-z]{2,})/', function ($matches) {
            // _2-letters is a region, _3+-letters is a variant
            return '_'.call_user_func(strlen($matches[1]) > 2 ? 'ucfirst' : 'strtoupper', $matches[1]);
        }, strtolower($locale));

        if ($this->loadMessagesFromFile($locale)) {
            parent::setLocale($locale);

            return true;
        }

        return false;
    }
1261748
public function setContextLocale($context, $locale)
    {
        if (isset($this->contextLocales[$context]) && $this->contextLocales[$context] == $locale) {
            return;
        }
        $this->contextLocales[$context] = $locale;
        if ($context === $this->activeContext) {
            $this->currentLocaleChanged($locale);
        }
    }
791842
public function setLocale($locale = null)
    {
        if (is_null($locale)) {
            $locale = $this->getParent()->getLocale();
        }
        $this->locale = $locale;

        return $this;
    }
927451
public function setLocale($locale)
    {
        // Setup the Framework locale.
        $this->locale = $locale;

        // Retrieve the full locale from languages list.
        $language = array_get($this->languages, $locale .'.locale', 'en_US') .'.utf8';

        // Setup the Carbon and PHP's time locale.
        setlocale(LC_TIME, $language);

        Carbon::setLocale($locale);
    }
1018084
private function setlocale() {
        foreach ($this->codeSets as $code) {
            if (substr($code, 0, strlen($this->loadedLang)) === $this->loadedLang) {
                setlocale(LC_TIME, $code);
                break;
            }
        }
    }
1190913
public function setLocale($locale)
    {
        /** @var Config $config */
        $config = $this->get('config');
        $config->set('app.locale.selected', $locale);

        /** @noinspection PhpUndefinedMethodInspection */
        $this->get('translator')->setLocale($locale);
    }
867715
public void setLocale(Locale locale) {
		if (!initialized) {
			super.setLocale(locale);
		} else {
			this.locale = locale;
			super.setLocale(locale);
			init();
		}
	}