Set the user's currently selected Locale.

@param request The request we are processing
@param locale  The user's selected Locale to be set, or null
to select the server's default Locale
@deprecated Use {@link #setLocale(Locale)}.
779527
protected void setLocale( HttpServletRequest request, Locale locale )
    {

        HttpSession session = request.getSession();
        if ( locale == null )
        {
            locale = getDefaultLocale();
        }
        session.setAttribute( Globals.LOCALE_KEY, locale );

    }
775435
public static synchronized void setLocale(String newLocale) throws UnsupportedLocaleException {
        Preconditions.checkArgument(newLocale == null, "newLocale == null");
        if (!newLocale.equals(CURRENT_LOCALE)) {
            LogCentral.setLocale(newLocale);
            CURRENT_LOCALE = newLocale;
        }
    }
308773
public function detectLocale(HTTPRequest $request)
    {
        // Given multiple canditates, narrow down the final result using the client's preferred languages
        $inputLocales = $request->getHeader('Accept-Language');
        if (empty($inputLocales)) {
            return null;
        }

        // Generate mapping of priority => list of locales at this priority
        // break up string into pieces (languages and q factors)
        preg_match_all(
            '/(?<code>[a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(?<priority>1|0\.[0-9]+))?/i',
            $inputLocales,
            $parsedLocales
        );

        $prioritisedLocales = [];
        if (count($parsedLocales['code'])) {
            // create a list like "en" => 0.8
            $parsedLocales = array_combine($parsedLocales['code'], $parsedLocales['priority']);

            // Generate nested list of priorities => [locales]
            foreach ($parsedLocales as $locale => $priority) {
                $priority = empty($priority) ? "1.0" : (string)floatval($priority);
                if (empty($prioritisedLocales[$priority])) {
                    $prioritisedLocales[$priority] = [];
                }
                $prioritisedLocales[$priority][] = $locale;
            }

            // sort list based on value
            krsort($prioritisedLocales, SORT_NUMERIC);
        }

        // Check each requested locale against loaded locales
        $locales = Locale::getLocales(true);
        foreach ($prioritisedLocales as $priority => $parsedLocales) {
            foreach ($parsedLocales as $browserLocale) {
                foreach ($locales as $localeObj) {
                    /** @var Locale $localeObj */
                    if ($localeObj->isLocale($browserLocale)) {
                        return $localeObj;
                    }
                }
            }
        }
        return null;
    }
1223612
protected void setLocale( Locale locale )
    {
        if ( locale == null ) locale = getDefaultLocale();
        getSession().setAttribute( Globals.LOCALE_KEY, locale );
    }
130599
public static function setLocale($locale=null)
    {
        global $CFG, $TSUGI_LOCALE, $TSUGI_LOCALE_RELOAD;

        // No internationalization support
        if ( isset($CFG->legacytranslation) ) {
            if ( ! function_exists('bindtextdomain') ) return;
            if ( ! function_exists('textdomain') ) return;
        }

        if ( isset($CFG->legacytranslation) && $locale && 
            strpos($locale, 'UTF-8') === false ) $locale = $locale . '.UTF-8';

        if ( $locale === null && isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) {

            if ( class_exists('\Locale') ) {
                try {
                    // Symfony may implement a stub for this function that throws an exception
                    $locale = \Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
                } catch (exception $e) { }
            }
            if ($locale === null) { // Crude fallback if we can't use Locale::acceptFromHttp
                $pieces = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
                $locale = $pieces[0];
            }
        }

        if ( $locale === null && isset($CFG->fallbacklocale) && $CFG->fallbacklocale ) {
            $locale = $CFG->fallbacklocale;
        }

        if ( $locale === null ) return;

        $locale = str_replace('-','_',$locale);
        if ( isset($CFG->legacytranslation) ) {
            putenv('LC_ALL='.$locale);
            setlocale(LC_ALL, $locale);
        }
        // error_log("setLocale=$locale");
        if ( $TSUGI_LOCALE != $locale ) $TSUGI_LOCALE_RELOAD = true;
        $TSUGI_LOCALE = $locale;
    }
463509
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)
        ));
    }
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);
    }
1294561
@Deprecated
    public TimeUnitFormat setLocale(ULocale locale) {
        if (locale != this.locale){
            mf = mf.withLocale(locale);

            // Needed for getLocale(ULocale.VALID_LOCALE)
            setLocale(locale, locale);
            this.locale = locale;
            isReady = false;
        }
        return this;
    }
719360
private void setLocale(Locale l, boolean select) {
		Locale oldLocale = locale;
		locale = l;
		int n = 0;

		if (select) {
			for (int i = 0; i < localeCount; i++) {
				if (locales[i].getCountry().length() > 0) {
					if (locales[i].equals(locale))
						setSelectedIndex(n);
					n += 1;
				}
			}
		}

		firePropertyChange("locale", oldLocale, locale);
		if(component != null) {
		    component.setLocale(l);
		}
	}
387326
public void setLocale(Locale newLocale) throws PropertyVetoException
	{
		if (newLocale == null || newLocale == locale)
		{
			return; // ignore null locale
		}

		PropertyChangeEvent event = new PropertyChangeEvent(beanContextChildPeer, "locale", locale, newLocale);

		// apply change
		Locale oldLocale = locale;
		locale = newLocale;

		try
		{
			// notify vetoable listeners
			vcSupport.fireVetoableChange(event);
		}
		catch (PropertyVetoException e)
		{
			// rollback change
			locale = oldLocale;
			throw e;
		}
		// Notify BeanContext about this change
		this.pcSupport.firePropertyChange(event);
	}
558723
public String resolveLocaleCode(HttpServletRequest request) {
		org.springframework.web.servlet.LocaleResolver resolver = RequestContextUtils.getLocaleResolver(request);
		Locale resolved = resolver.resolveLocale(request);
		if(resolved != Locale.getDefault())
			return resolved.toString();
		else return null;
	}
254118
public function setDefaultLocale($locale) {

		$this->defaultLocale = $locale;

		if (NULL === $this->locale) {
			$this->setPhpDefaultLocale($locale);
		}

	}
19109
public void setRequest(Object request)
    {
        ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
        
        if (ctx == null)
        {
            throw new UnsupportedOperationException();
        }
        
        ctx.setRequest(request);
    }
1217995
public void setLocale(Locale locale)
  {
    if(locale != null && report != null && report instanceof LocalizableReport) 
    {
      ((LocalizableReport) report).setLocale(locale); 
    }
  }
1118327
public void setDefault(E value, Locale locale) {
    set(value, locale);
    this.defaultLocale = locale;
  }
1142436
public function setLocale(SetLocaleRequest $request)
    {
        $locale = $request->input('locale');

        if ( ! $this->repository->isAvailable($locale)) {
            return redirect()->back()->withErrors("Locale {$locale} is not available");
        }

        session()->put($this->getSessionKey(), $locale);

        return redirect()->back();
    }
606583
protected Locale getLocale(RequestContext context) {
    return this.locale != null ? this.locale : context.getExternalContext().getLocale();
  }