Gets the default I18N localization context.

@param pc Page in which to look up the default I18N localization context
974296
public static LocalizationContext getLocalizationContext(PageContext pc) {
        LocalizationContext locCtxt = null;

        Object obj = Config.find(pc, Config.FMT_LOCALIZATION_CONTEXT);
        if (obj == null) {
            return null;
        }

        if (obj instanceof LocalizationContext) {
            locCtxt = (LocalizationContext) obj;
        } else {
            // localization context is a bundle basename
            locCtxt = getLocalizationContext(pc, (String) obj);
        }

        return locCtxt;
    }
1151781
public static String getLocalisedText(final Locale locale, final String text) {
		String message = null;
		String resourceBundleBaseName = getResourceBundleBaseName();

		if (!Util.empty(resourceBundleBaseName)) {
			Locale effectiveLocale = locale;

			if (effectiveLocale == null) {
				effectiveLocale = getEffectiveLocale();
			}

			try {
				// TODO: This is slow
				ResourceBundle bundle = ResourceBundle.getBundle(resourceBundleBaseName, effectiveLocale);
				message = bundle.getString(text);
			} catch (MissingResourceException e) {
				// Fall back to the Configuration mechanism for the default internal messages
				if (text != null && text.startsWith(ConfigurationProperties.INTERNAL_MESSAGE_PREFIX)) {
					message = ConfigurationProperties.getInternalMessage(text);
				}

				if (message == null && !MISSING_RESOURCES.contains(locale)) {
					LOG.error("Missing resource mapping for locale: " + locale + ", text: " + text);
					MISSING_RESOURCES.add(locale);
				}
			}
		} else if (text != null && text.startsWith(ConfigurationProperties.INTERNAL_MESSAGE_PREFIX)) {
			// Fall back to the Configuration mechanism for the default internal messages
			message = ConfigurationProperties.getInternalMessage(text);
		}

		return message;
	}
1226126
@Override
    public List<Locale> getLocales(String acceptLangHdr) {
        // Short circuit with an empty enumeration if null header
        if (null == acceptLangHdr) {
            List<Locale> def = new ArrayList<Locale>(1);
            def.add(Locale.getDefault());
            return def;
        }

        // Check cache
        List<Locale> langList = this.localesCache.get(acceptLangHdr);
        if (null == langList) {
            // Create and add to cache
            List<List<String>> rc = processAcceptLanguage(acceptLangHdr);
            if (null != rc) {
                langList = extractLocales(rc);
                this.localesCache.put(acceptLangHdr, langList);
            } else {
                // this can happen with only q=0 values in the header
                List<Locale> def = new ArrayList<Locale>(1);
                def.add(Locale.getDefault());
                return def;
            }
        }

        return langList;
    }
492396
def i18n_system_locale():
    
    log.debug('i18n_system_locale() called')
    lc, encoding = locale.getlocale()
    log.debug('locale.getlocale() = (lc="{lc}", encoding="{encoding}).'.format(lc=lc, encoding=encoding))
    if lc is None:
        lc, encoding = locale.getdefaultlocale()
        log.debug('locale.getdefaultlocale() = (lc="{lc}", encoding="{encoding}).'.format(lc=lc, encoding=encoding))
    return lc
735858
public Locale getWorkplaceLocale(CmsRequestContext requestContext) {

        Locale wpLocale = new CmsUserSettings(requestContext.getCurrentUser()).getLocale();
        if (wpLocale == null) {
            // fall back
            wpLocale = getDefaultLocale();
            if (wpLocale == null) {
                // fall back
                wpLocale = requestContext.getLocale();
            }
        }
        return wpLocale;

    }
357782
def get_language_from_request(request):
    """"""
    language = request.GET.get('language', None)
    if language:
        return language

    if hasattr(request, 'LANGUAGE_CODE'):
        lang = settings.PAGE_LANGUAGE_MAPPING(str(request.LANGUAGE_CODE))
        if lang not in LANGUAGE_KEYS:
            return settings.PAGE_DEFAULT_LANGUAGE
        else:
            return lang
    else:
        return settings.PAGE_DEFAULT_LANGUAGE
473604
private Locale getLocale(FacesContext context) {

        // PENDING(craigmcc) - JSTL localization context?
        Locale locale = this.locale;
        if (locale == null) {
            locale = context.getViewRoot().getLocale();
        }
        return (locale);

    }
606583
protected Locale getLocale(RequestContext context) {
    return this.locale != null ? this.locale : context.getExternalContext().getLocale();
  }
477419
static Locale getFormattingLocale(PageContext pc) {
        /*
       * Establish formatting locale by comparing the preferred locales
       * (in order of preference) against the available formatting
       * locales, and determining the best matching locale.
       */
        Locale match;
        Locale pref = getLocale(pc, Config.FMT_LOCALE);
        if (pref != null) {
            // Preferred locale is application-based
            match = findFormattingMatch(pref, availableFormattingLocales);
        } else {
            // Preferred locales are browser-based
            match = findFormattingMatch(pc, availableFormattingLocales);
        }
        if (match == null) {
            //Use fallback locale.
            pref = getLocale(pc, Config.FMT_FALLBACK_LOCALE);
            if (pref != null) {
                match = findFormattingMatch(pref, availableFormattingLocales);
            }
        }
        if (match != null) {
            setResponseLocale(pc, match);
        }

        return match;
    }
1356403
public String getLanguageOrDefault(RouteContext routeContext) {
        final String cookieName = generateLanguageCookie(defaultLanguage).getName();

        // Step 1: Look for a Response cookie.
        // The Response always has priority over the Request because it may have
        // been set earlier in the HandlerChain.
        Cookie cookie = routeContext.getResponse().getCookie(cookieName);
        if (cookie != null && !StringUtils.isNullOrEmpty(cookie.getValue())) {
            return getLanguageOrDefault(cookie.getValue());
        }

        // Step 2: Look for a Request cookie.
        cookie = routeContext.getRequest().getCookie(cookieName);
        if (cookie != null && !StringUtils.isNullOrEmpty(cookie.getValue())) {
            return getLanguageOrDefault(cookie.getValue());
        }

        // Step 3: Look for a lang parameter in the response locals
        if (routeContext.getResponse().getLocals().containsKey(PippoConstants.REQUEST_PARAMETER_LANG)) {
            String language = routeContext.getLocal(PippoConstants.REQUEST_PARAMETER_LANG);
            language = getLanguageOrDefault(language);
            return language;
        }

        // Step 4: Look for a language in the Accept-Language header.
        String acceptLanguage = routeContext.getHeader(HttpConstants.Header.ACCEPT_LANGUAGE);
        return getLanguageOrDefault(acceptLanguage);
    }
805641
def desk_locale(self, locale):
        """"""

        locale = locale.lower().replace('-', '_')
        return self.vendor_locale_map.get(locale, locale)
1308108
public static Object getVariableEL(PageContext pc, String var, Object defaultValue) {
	StringList list = parse(pc, new ParserString(var), false);
	if (list == null) return defaultValue;

	int scope = scopeString2Int(pc.ignoreScopes(), list.next());
	Object coll = null;
	if (scope == Scope.SCOPE_UNDEFINED) {
	    coll = pc.undefinedScope().get(KeyImpl.init(list.current()), NullSupportHelper.NULL());
	    if (coll == NullSupportHelper.NULL()) return defaultValue;
	}
	else {
	    try {
		coll = VariableInterpreter.scope(pc, scope, list.hasNext());
		// coll=pc.scope(scope);
	    }
	    catch (PageException e) {
		return defaultValue;
	    }
	}

	while (list.hasNext()) {
	    coll = pc.getVariableUtil().get(pc, coll, KeyImpl.init(list.next()), NullSupportHelper.NULL());
	    if (coll == NullSupportHelper.NULL()) return defaultValue;
	}
	return coll;
    }
1026188
def pages_siblings_menu(context, page, url='/'):
    
    lang = context.get('lang', pages_settings.PAGE_DEFAULT_LANGUAGE)
    page = get_page_from_string_or_id(page, lang)
    if page:
        if page.parent:
            root = page.parent
        else:
            root = page
        children = root.get_children_for_frontend()
        context.update({'children': children, 'page': page})
    return context
646587
private void setContext(IWorkbenchPage page, IVdmStackFrame frame)
	{
		// pageToContextMap.put(page, frame);
		//		System.setProperty(DEBUGGER_ACTIVE, "true"); //$NON-NLS-1$

		/*
		 * if (frame.canForceReturn()) { System.setProperty(SUPPORTS_FORCE_RETURN, "true"); //$NON-NLS-1$ } else {
		 * System.setProperty(SUPPORTS_FORCE_RETURN, "false"); //$NON-NLS-1$ } if
		 * (((IVdmStackFrame)frame.getDebugTarget()).supportsInstanceRetrieval()){
		 * System.setProperty(SUPPORTS_INSTANCE_RETRIEVAL, "true"); //$NON-NLS-1$ } else {
		 * System.setProperty(SUPPORTS_INSTANCE_RETRIEVAL, "false"); //$NON-NLS-1$ } if (instOf) {
		 * System.setProperty(INSTANCE_OF_IJAVA_STACK_FRAME, "true"); //$NON-NLS-1$ } else {
		 * System.setProperty(INSTANCE_OF_IJAVA_STACK_FRAME, "false"); //$NON-NLS-1$ }
		 */

		if (fContextsByPage == null)
		{
			fContextsByPage = new HashMap<IWorkbenchPage, IVdmStackFrame>();
		}
		fContextsByPage.put(page, frame);
		System.setProperty(DEBUGGER_ACTIVE, "true"); //$NON-NLS-1$
		// if (frame.canForceReturn()) {
		//			System.setProperty(SUPPORTS_FORCE_RETURN, "true"); //$NON-NLS-1$
		// } else {
		//			System.setProperty(SUPPORTS_FORCE_RETURN, "false"); //$NON-NLS-1$
		// }
		// if (((IJavaDebugTarget)frame.getDebugTarget()).supportsInstanceRetrieval()){
		//			System.setProperty(SUPPORTS_INSTANCE_RETRIEVAL, "true"); //$NON-NLS-1$
		// } else {
		//			System.setProperty(SUPPORTS_INSTANCE_RETRIEVAL, "false"); //$NON-NLS-1$
		// }
		// if (instOf) {
		//			System.setProperty(INSTANCE_OF_IJAVA_STACK_FRAME, "true"); //$NON-NLS-1$
		// } else {
		//			System.setProperty(INSTANCE_OF_IJAVA_STACK_FRAME, "false"); //$NON-NLS-1$
		// }
	}
1235535
void ensureSingleLocale(CmsXmlContainerPage containerPage, CmsResource localeRes) throws CmsException {

        CmsObject cms = getCmsObject();
        Locale mainLocale = CmsLocaleManager.getMainLocale(cms, localeRes);
        OpenCms.getLocaleManager();
        Locale defaultLocale = CmsLocaleManager.getDefaultLocale();
        if (containerPage.hasLocale(mainLocale)) {
            removeAllLocalesExcept(containerPage, mainLocale);
            // remove other locales
        } else if (containerPage.hasLocale(defaultLocale)) {
            containerPage.copyLocale(defaultLocale, mainLocale);
            removeAllLocalesExcept(containerPage, mainLocale);
        } else if (containerPage.getLocales().size() > 0) {
            containerPage.copyLocale(containerPage.getLocales().get(0), mainLocale);
            removeAllLocalesExcept(containerPage, mainLocale);
        } else {
            containerPage.addLocale(cms, mainLocale);
        }
    }
569503
public Locale getLocaleOrDefault(RouteContext routeContext) {
        String language = getLanguageOrDefault(routeContext);
        return Locale.forLanguageTag(language);
    }
1222199
public function getLocale() : ?string 
    {
        if ( ! $this->hasLocale()) {
            $this->setLocale($this->getDefaultLocale());
        }
        return $this->locale;
    }