List of usage examples for java.util Locale getDisplayName
public String getDisplayName(Locale inLocale)
From source file:com.ecyrd.jspwiki.ui.TemplateManager.java
/** * List all installed i18n language properties * /* w ww. j a va 2 s .co m*/ * @param pageContext * @return map of installed Languages (with help of Juan Pablo Santos Rodriguez) * @since 2.7.x */ public Map listLanguages(PageContext pageContext) { LinkedHashMap<String, String> resultMap = new LinkedHashMap<String, String>(); String clientLanguage = ((HttpServletRequest) pageContext.getRequest()).getLocale().toString(); JarInputStream jarStream = null; try { JarEntry entry; InputStream inputStream = pageContext.getServletContext().getResourceAsStream(I18NRESOURCE_PATH); jarStream = new JarInputStream(inputStream); while ((entry = jarStream.getNextJarEntry()) != null) { String name = entry.getName(); if (!entry.isDirectory() && name.startsWith(I18NRESOURCE_PREFIX) && name.endsWith(I18NRESOURCE_SUFFIX)) { name = name.substring(I18NRESOURCE_PREFIX.length(), name.lastIndexOf(I18NRESOURCE_SUFFIX)); Locale locale = new Locale(name.substring(0, 2), ((name.indexOf("_") == -1) ? "" : name.substring(3, 5))); String defaultLanguage = ""; if (clientLanguage.startsWith(name)) { defaultLanguage = LocaleSupport.getLocalizedMessage(pageContext, I18NDEFAULT_LOCALE); } resultMap.put(name, locale.getDisplayName(locale) + " " + defaultLanguage); } } } catch (IOException ioe) { if (log.isDebugEnabled()) log.debug("Could not search jar file '" + I18NRESOURCE_PATH + "'for properties files due to an IOException: \n" + ioe.getMessage()); } finally { if (jarStream != null) { try { jarStream.close(); } catch (IOException e) { } } } return resultMap; }
From source file:org.opencms.workplace.editors.CmsEditor.java
/** * Builds the html String for the element language selector.<p> * /*w ww .j a v a 2s. c om*/ * @param attributes optional attributes for the <select> tag * @param resourceName the name of the resource to edit * @param selectedLocale the currently selected Locale * @return the html for the element language selectbox */ public String buildSelectElementLanguage(String attributes, String resourceName, Locale selectedLocale) { // get locale names based on properties and global settings List locales = OpenCms.getLocaleManager().getAvailableLocales(getCms(), resourceName); List options = new ArrayList(locales.size()); List selectList = new ArrayList(locales.size()); int currentIndex = -1; //get the locales already used in the resource List contentLocales = new ArrayList(); try { CmsResource res = getCms().readResource(resourceName, CmsResourceFilter.IGNORE_EXPIRATION); String temporaryFilename = CmsWorkplace.getTemporaryFileName(resourceName); if (getCms().existsResource(temporaryFilename, CmsResourceFilter.IGNORE_EXPIRATION)) { res = getCms().readResource(temporaryFilename, CmsResourceFilter.IGNORE_EXPIRATION); } CmsFile file = getCms().readFile(res); CmsXmlContent xmlContent = CmsXmlContentFactory.unmarshal(getCms(), file); contentLocales = xmlContent.getLocales(); } catch (CmsException e) { // to nothing here in case the resource could not be opened if (LOG.isErrorEnabled()) { LOG.error(Messages.get().getBundle().key(Messages.LOG_GET_LOCALES_1, resourceName), e); } } for (int counter = 0; counter < locales.size(); counter++) { // create the list of options and values Locale curLocale = (Locale) locales.get(counter); selectList.add(curLocale.toString()); StringBuffer buf = new StringBuffer(); buf.append(curLocale.getDisplayName(getLocale())); if (!contentLocales.contains(curLocale)) { buf.append(EMPTY_LOCALE); } options.add(buf.toString()); if (curLocale.equals(selectedLocale)) { // set the selected index of the selector currentIndex = counter; } } if (currentIndex == -1) { // no matching element language found, use first element language in list if (selectList.size() > 0) { currentIndex = 0; setParamElementlanguage((String) selectList.get(0)); } } return buildSelect(attributes, options, selectList, currentIndex, false); }
From source file:org.jahia.ajax.gwt.helper.PublicationHelper.java
public List<GWTJahiaPublicationInfo> getFullPublicationInfos(List<String> uuids, Set<String> languages, JCRSessionWrapper currentUserSession, boolean allSubTree, boolean checkForUnpublication) throws GWTJahiaServiceException { try {// w ww . j av a 2 s . c o m if (!checkForUnpublication) { LinkedHashMap<String, GWTJahiaPublicationInfo> res = new LinkedHashMap<String, GWTJahiaPublicationInfo>(); for (String language : languages) { List<PublicationInfo> infos = publicationService.getPublicationInfos(uuids, Collections.singleton(language), true, true, allSubTree, currentUserSession.getWorkspace().getName(), Constants.LIVE_WORKSPACE); for (PublicationInfo info : infos) { info.clearInternalAndPublishedReferences(uuids); } final List<GWTJahiaPublicationInfo> infoList = convert(infos, currentUserSession, language, "publish"); String lastGroup = null; String lastTitle = null; Locale l = new Locale(language); for (GWTJahiaPublicationInfo info : infoList) { if (((info.isPublishable() || info.getStatus() == GWTJahiaPublicationInfo.MANDATORY_LANGUAGE_UNPUBLISHABLE) && (info.getWorkflowDefinition() != null || info.isAllowedToPublishWithoutWorkflow()))) { res.put(language + "/" + info.getUuid(), info); if (lastGroup == null || !info.getWorkflowGroup().equals(lastGroup)) { lastGroup = info.getWorkflowGroup(); lastTitle = info.getTitle() + " ( " + l.getDisplayName(l) + " )"; } info.setWorkflowTitle(lastTitle); } } } return new ArrayList<GWTJahiaPublicationInfo>(res.values()); } else { List<PublicationInfo> infos = publicationService.getPublicationInfos(uuids, null, false, true, allSubTree, currentUserSession.getWorkspace().getName(), Constants.LIVE_WORKSPACE); LinkedHashMap<String, GWTJahiaPublicationInfo> res = new LinkedHashMap<String, GWTJahiaPublicationInfo>(); for (String language : languages) { final List<GWTJahiaPublicationInfo> infoList = convert(infos, currentUserSession, language, "unpublish"); String lastGroup = null; String lastTitle = null; Locale l = new Locale(language); for (GWTJahiaPublicationInfo info : infoList) { if ((info.getStatus() == GWTJahiaPublicationInfo.PUBLISHED && (info.getWorkflowDefinition() != null || info.isAllowedToPublishWithoutWorkflow()))) { res.put(language + "/" + info.getUuid(), info); if (lastGroup == null || !info.getWorkflowGroup().equals(lastGroup)) { lastGroup = info.getWorkflowGroup(); lastTitle = info.getTitle() + " ( " + l.getDisplayName(l) + " )"; } info.setWorkflowTitle(lastTitle); } } } for (PublicationInfo info : infos) { Set<String> publishedLanguages = info.getAllPublishedLanguages(); if (!languages.containsAll(publishedLanguages)) { keepOnlyTranslation(res); } } return new ArrayList<GWTJahiaPublicationInfo>(res.values()); } } catch (RepositoryException e) { logger.error("repository exception", e); throw new GWTJahiaServiceException( "Cannot get publication status for nodes " + uuids + ". Cause: " + e.getLocalizedMessage(), e); } }
From source file:org.jahia.modules.rolesmanager.RolesAndPermissionsHandler.java
private RoleBean createRoleBean(JCRNodeWrapper role, boolean getPermissions, boolean getSubRoles) throws RepositoryException { RoleBean roleBean = new RoleBean(); JCRNodeWrapper parentRole = JCRContentUtils.getParentOfType(role, "jnt:role"); final String uuid = role.getIdentifier(); roleBean.setUuid(uuid);/*from w w w. j av a 2 s . co m*/ roleBean.setParentUuid(parentRole != null ? parentRole.getIdentifier() : null); roleBean.setName(role.getName()); roleBean.setPath(role.getPath()); roleBean.setDepth(role.getDepth()); JCRNodeWrapper n; Map<String, I18nRoleProperties> i18nRoleProperties = new TreeMap<String, I18nRoleProperties>(); for (Locale l : role.getExistingLocales()) { n = getSession(l).getNodeByIdentifier(uuid); if (!n.hasProperty(Constants.JCR_TITLE) && !n.hasProperty(Constants.JCR_DESCRIPTION)) { i18nRoleProperties.put(l.getLanguage(), null); continue; } I18nRoleProperties properties = new I18nRoleProperties(); properties.setLanguage(l.getDisplayName(LocaleContextHolder.getLocale())); if (n.hasProperty(Constants.JCR_TITLE)) { properties.setTitle(n.getProperty(Constants.JCR_TITLE).getString()); } if (n.hasProperty(Constants.JCR_DESCRIPTION)) { properties.setDescription(n.getProperty(Constants.JCR_DESCRIPTION).getString()); } i18nRoleProperties.put(l.getLanguage(), properties); } roleBean.setI18nProperties(i18nRoleProperties); if (role.hasProperty("j:hidden")) { roleBean.setHidden(role.getProperty("j:hidden").getBoolean()); } String roleGroup = "edit-role"; if (role.hasProperty("j:roleGroup")) { roleGroup = role.getProperty("j:roleGroup").getString(); } RoleType roleType = roleTypes.get(roleGroup); roleBean.setRoleType(roleType); if (getPermissions) { List<String> tabs = new ArrayList<String>(roleBean.getRoleType().getScopes()); Map<String, List<String>> permIdsMap = new HashMap<String, List<String>>(); fillPermIds(role, tabs, permIdsMap, false); Map<String, List<String>> inheritedPermIdsMap = new HashMap<String, List<String>>(); fillPermIds(role.getParent(), tabs, inheritedPermIdsMap, true); Map<String, Map<String, Map<String, PermissionBean>>> permsForRole = new LinkedHashMap<String, Map<String, Map<String, PermissionBean>>>(); roleBean.setPermissions(permsForRole); for (String tab : tabs) { addPermissionsForScope(roleBean, tab, permIdsMap, inheritedPermIdsMap); } if (roleType.getAvailableNodeTypes() != null) { List<String> nodeTypesOnRole = new ArrayList<String>(); if (role.hasProperty("j:nodeTypes")) { for (Value value : role.getProperty("j:nodeTypes").getValues()) { nodeTypesOnRole.add(value.getString()); } } SortedSet<NodeType> nodeTypes = new TreeSet<NodeType>(); for (String s : roleType.getAvailableNodeTypes()) { boolean includeSubtypes = false; if (s.endsWith("/*")) { s = StringUtils.substringBeforeLast(s, "/*"); includeSubtypes = true; } ExtendedNodeType t = NodeTypeRegistry.getInstance().getNodeType(s); nodeTypes.add(new NodeType(t.getName(), t.getLabel(LocaleContextHolder.getLocale()), nodeTypesOnRole.contains(t.getName()))); if (includeSubtypes) { for (ExtendedNodeType sub : t.getSubtypesAsList()) { nodeTypes.add(new NodeType(sub.getName(), sub.getLabel(LocaleContextHolder.getLocale()), nodeTypesOnRole.contains(sub.getName()))); } } } roleBean.setNodeTypes(nodeTypes); } } // sub-roles if (getSubRoles) { final List<JCRNodeWrapper> subRoles = JCRContentUtils.getNodes(role, "jnt:role"); final List<RoleBean> subRoleBeans = new ArrayList<RoleBean>(subRoles.size()); for (JCRNodeWrapper subRole : subRoles) { subRoleBeans.add(createRoleBean(subRole, false, false)); } roleBean.setSubRoles(subRoleBeans); } return roleBean; }
From source file:ch.cyberduck.core.preferences.Preferences.java
/** * @param locale ISO Language identifier * @return Human readable language name in the target language *///from w w w .j av a 2s.co m public String getDisplayName(final String locale) { java.util.Locale l; if (StringUtils.contains(locale, "_")) { l = new java.util.Locale(locale.split("_")[0], locale.split("_")[1]); } else { l = new java.util.Locale(locale); } return StringUtils.capitalize(l.getDisplayName(l)); }
From source file:org.opencms.ade.contenteditor.CmsContentService.java
/** * Reads the content definition for the given resource and locale.<p> * * @param file the resource file//from w w w . ja v a 2 s.c o m * @param content the XML content * @param entityId the entity id * @param locale the content locale * @param newLocale if the locale content should be created as new * @param mainLocale the main language to copy in case the element language node does not exist yet * @param editedLocaleEntity the edited locale entity * * @return the content definition * * @throws CmsException if something goes wrong */ private CmsContentDefinition readContentDefinition(CmsFile file, CmsXmlContent content, String entityId, Locale locale, boolean newLocale, Locale mainLocale, CmsEntity editedLocaleEntity) throws CmsException { long timer = 0; if (LOG.isDebugEnabled()) { timer = System.currentTimeMillis(); } CmsObject cms = getCmsObject(); List<Locale> availableLocalesList = OpenCms.getLocaleManager().getAvailableLocales(cms, file); if (!availableLocalesList.contains(locale)) { availableLocalesList.retainAll(content.getLocales()); List<Locale> defaultLocales = OpenCms.getLocaleManager().getDefaultLocales(cms, file); Locale replacementLocale = OpenCms.getLocaleManager().getBestMatchingLocale(locale, defaultLocales, availableLocalesList); LOG.info("Can't edit locale " + locale + " of file " + file.getRootPath() + " because it is not configured as available locale. Using locale " + replacementLocale + " instead."); locale = replacementLocale; entityId = CmsContentDefinition.uuidToEntityId(file.getStructureId(), locale.toString()); } if (CmsStringUtil.isEmptyOrWhitespaceOnly(entityId)) { entityId = CmsContentDefinition.uuidToEntityId(file.getStructureId(), locale.toString()); } boolean performedAutoCorrection = checkAutoCorrection(cms, content); if (performedAutoCorrection) { content.initDocument(); } if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_TAKE_UNMARSHALING_TIME_1, "" + (System.currentTimeMillis() - timer))); } CmsContentTypeVisitor visitor = new CmsContentTypeVisitor(cms, file, locale); if (LOG.isDebugEnabled()) { timer = System.currentTimeMillis(); } visitor.visitTypes(content.getContentDefinition(), getWorkplaceLocale(cms)); if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_TAKE_VISITING_TYPES_TIME_1, "" + (System.currentTimeMillis() - timer))); } CmsEntity entity = null; Map<String, String> syncValues = new HashMap<String, String>(); Collection<String> skipPaths = new HashSet<String>(); evaluateSyncLocaleValues(content, syncValues, skipPaths); if (content.hasLocale(locale) && newLocale) { // a new locale is requested, so remove the present one content.removeLocale(locale); } if (!content.hasLocale(locale)) { if ((mainLocale != null) && content.hasLocale(mainLocale)) { content.copyLocale(mainLocale, locale); } else { content.addLocale(cms, locale); } // sync the locale values if (!visitor.getLocaleSynchronizations().isEmpty() && (content.getLocales().size() > 1)) { for (Locale contentLocale : content.getLocales()) { if (!contentLocale.equals(locale)) { content.synchronizeLocaleIndependentValues(cms, skipPaths, contentLocale); } } } } Element element = content.getLocaleNode(locale); if (LOG.isDebugEnabled()) { timer = System.currentTimeMillis(); } entity = readEntity(content, element, locale, entityId, "", getTypeUri(content.getContentDefinition()), visitor, false, editedLocaleEntity); if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_TAKE_READING_ENTITY_TIME_1, "" + (System.currentTimeMillis() - timer))); } List<String> contentLocales = new ArrayList<String>(); for (Locale contentLocale : content.getLocales()) { contentLocales.add(contentLocale.toString()); } Locale workplaceLocale = OpenCms.getWorkplaceManager().getWorkplaceLocale(cms); TreeMap<String, String> availableLocales = new TreeMap<String, String>(); for (Locale availableLocale : OpenCms.getLocaleManager().getAvailableLocales(cms, file)) { availableLocales.put(availableLocale.toString(), availableLocale.getDisplayName(workplaceLocale)); } String title = cms.readPropertyObject(file, CmsPropertyDefinition.PROPERTY_TITLE, false).getValue(); try { CmsGallerySearchResult searchResult = CmsGallerySearch.searchById(cms, file.getStructureId(), locale); title = searchResult.getTitle(); } catch (CmsException e) { LOG.warn(e.getLocalizedMessage(), e); } String typeName = OpenCms.getResourceManager().getResourceType(file.getTypeId()).getTypeName(); boolean autoUnlock = OpenCms.getWorkplaceManager().shouldAcaciaUnlock(); Map<String, CmsEntity> entities = new HashMap<String, CmsEntity>(); entities.put(entityId, entity); return new CmsContentDefinition(entityId, entities, visitor.getAttributeConfigurations(), visitor.getWidgetConfigurations(), visitor.getComplexWidgetData(), visitor.getTypes(), visitor.getTabInfos(), locale.toString(), contentLocales, availableLocales, visitor.getLocaleSynchronizations(), syncValues, skipPaths, title, cms.getSitePath(file), typeName, performedAutoCorrection, autoUnlock, getChangeHandlerScopes(content.getContentDefinition())); }
From source file:org.apache.maven.doxia.tools.DefaultSiteTool.java
/** {@inheritDoc} */ public List<Locale> getSiteLocales(String locales) { if (locales == null) { return Collections.singletonList(DEFAULT_LOCALE); }// www .j av a2 s . c o m String[] localesArray = StringUtils.split(locales, ","); List<Locale> localesList = new ArrayList<Locale>(localesArray.length); for (String localeString : localesArray) { Locale locale = codeToLocale(localeString); if (locale == null) { continue; } if (!Arrays.asList(Locale.getAvailableLocales()).contains(locale)) { if (getLogger().isWarnEnabled()) { getLogger().warn( "The locale defined by '" + locale + "' is not available in this Java Virtual Machine (" + System.getProperty("java.version") + " from " + System.getProperty("java.vendor") + ") - IGNORING"); } continue; } // Default bundles are in English if ((!locale.getLanguage().equals(DEFAULT_LOCALE.getLanguage())) && (!i18n .getBundle("site-tool", locale).getLocale().getLanguage().equals(locale.getLanguage()))) { if (getLogger().isWarnEnabled()) { getLogger().warn("The locale '" + locale + "' (" + locale.getDisplayName(Locale.ENGLISH) + ") is not currently supported by Maven Site - IGNORING." + "\nContributions are welcome and greatly appreciated!" + "\nIf you want to contribute a new translation, please visit " + "http://maven.apache.org/plugins/localization.html for detailed instructions."); } continue; } localesList.add(locale); } if (localesList.isEmpty()) { localesList = Collections.singletonList(DEFAULT_LOCALE); } return localesList; }
From source file:org.opencms.ui.editors.messagebundle.CmsMessageBundleEditorModel.java
/** * Returns the context menu for the table item. * @param itemId the table item.// www. j a va 2s . co m * @return the context menu for the given item. */ public CmsContextMenu getContextMenuForItem(Object itemId) { CmsContextMenu result = null; try { final Item item = m_container.getItem(itemId); Property<?> keyProp = item.getItemProperty(TableProperty.KEY); String key = (String) keyProp.getValue(); if ((null != key) && !key.isEmpty()) { loadAllRemainingLocalizations(); final Map<Locale, String> localesWithEntries = new HashMap<Locale, String>(); for (Locale l : m_localizations.keySet()) { if (l != m_locale) { String value = m_localizations.get(l).getProperty(key); if ((null != value) && !value.isEmpty()) { localesWithEntries.put(l, value); } } } if (!localesWithEntries.isEmpty()) { result = new CmsContextMenu(); ContextMenuItem mainItem = result.addItem(Messages.get().getBundle(UI.getCurrent().getLocale()) .key(Messages.GUI_BUNDLE_EDITOR_CONTEXT_COPY_LOCALE_0)); for (final Locale l : localesWithEntries.keySet()) { ContextMenuItem menuItem = mainItem.addItem(l.getDisplayName(UI.getCurrent().getLocale())); menuItem.addItemClickListener(new ContextMenuItemClickListener() { public void contextMenuItemClicked(ContextMenuItemClickEvent event) { item.getItemProperty(TableProperty.TRANSLATION).setValue(localesWithEntries.get(l)); } }); } } } } catch (Exception e) { LOG.error(e); //TODO: Improve } return result; }
From source file:org.opencms.ade.galleries.CmsGalleryService.java
/** * Returns a map with the available locales.<p> * * The map entry key is the current locale and the value the localized nice name.<p> * * @return the map representation of all available locales *///from w w w . j a v a 2 s .co m private Map<String, String> buildLocalesMap() { TreeMap<String, String> localesMap = new TreeMap<String, String>(); Iterator<Locale> it = OpenCms.getLocaleManager().getAvailableLocales().iterator(); while (it.hasNext()) { Locale locale = it.next(); localesMap.put(locale.toString(), locale.getDisplayName(getWorkplaceLocale())); } return localesMap; }
From source file:org.jahia.ajax.gwt.utils.GWTInitializer.java
public static String generateInitializerStructure(HttpServletRequest request, HttpSession session, Locale locale, Locale uilocale) { StringBuilder buf = new StringBuilder(); JahiaUser user = (JahiaUser) session.getAttribute(Constants.SESSION_USER); if (uilocale == null) { Locale sessionLocale = (Locale) session.getAttribute(Constants.SESSION_UI_LOCALE); JCRUserNode userNode = null;// w w w . j a v a 2 s.c om if (user != null) { userNode = JahiaUserManagerService.getInstance().lookupUserByPath(user.getLocalPath()); } uilocale = sessionLocale != null ? UserPreferencesHelper.getPreferredLocale(userNode, sessionLocale) : UserPreferencesHelper.getPreferredLocale(userNode, LanguageCodeConverters.resolveLocaleForGuest(request)); } if (locale == null) { String language = request.getParameter("lang"); if (!StringUtils.isEmpty(language)) { locale = LanguageCodeConverters.getLocaleFromCode(language); } if (locale == null) { locale = (Locale) session.getAttribute(Constants.SESSION_LOCALE); } if (locale == null) { locale = Locale.ENGLISH; } } buf.append("<meta name=\"gwt:property\" content=\"locale=") .append(StringEscapeUtils.escapeXml(uilocale.toString())).append("\"/>"); addCss(buf, request, false); // creat parameters map Map<String, String> params = new HashMap<String, String>(); RenderContext renderContext = (RenderContext) request.getAttribute("renderContext"); String serviceEntrypoint = buildServiceBaseEntrypointUrl(request); params.put(JahiaGWTParameters.SERVICE_ENTRY_POINT, serviceEntrypoint); String contextPath = request.getContextPath(); params.put(JahiaGWTParameters.CONTEXT_PATH, contextPath); params.put(JahiaGWTParameters.SERVLET_PATH, (request.getAttribute("servletPath") == null) ? request.getServletPath() : (String) request.getAttribute("servletPath")); params.put(JahiaGWTParameters.PATH_INFO, request.getPathInfo()); params.put(JahiaGWTParameters.QUERY_STRING, request.getQueryString()); boolean devMode = SettingsBean.getInstance().isDevelopmentMode(); params.put(JahiaGWTParameters.DEVELOPMENT_MODE, devMode ? "true" : "false"); boolean areaAutoActivated = SettingsBean.getInstance().isAreaAutoActivated(); params.put(JahiaGWTParameters.AREA_AUTO_ACTIVATED, areaAutoActivated ? "true" : "false"); if (devMode) { params.put(JahiaGWTParameters.MODULES_SOURCES_DISK_PATH, StringEscapeUtils.escapeJavaScript(SettingsBean.getInstance().getModulesSourcesDiskPath())); } if (user != null) { String name = user.getUsername(); int index = name.indexOf(":"); if (index > 0) { String displayname = name.substring(0, index); params.put(JahiaGWTParameters.CURRENT_USER_NAME, displayname); } else { params.put(JahiaGWTParameters.CURRENT_USER_NAME, name); } params.put(JahiaGWTParameters.CURRENT_USER_PATH, user.getLocalPath()); } else { params.put(JahiaGWTParameters.CURRENT_USER_NAME, "guest"); params.put(JahiaGWTParameters.CURRENT_USER_PATH, "/users/guest"); } params.put(JahiaGWTParameters.LANGUAGE, locale.toString()); params.put(JahiaGWTParameters.LANGUAGE_DISPLAY_NAME, WordUtils.capitalizeFully(locale.getDisplayName(locale))); params.put(JahiaGWTParameters.UI_LANGUAGE, uilocale.toString()); params.put(JahiaGWTParameters.UI_LANGUAGE_DISPLAY_NAME, WordUtils.capitalizeFully(uilocale.getDisplayName(uilocale))); try { if (renderContext != null) { params.put(JahiaGWTParameters.WORKSPACE, renderContext.getMainResource().getWorkspace()); if (renderContext.getSite() != null) { params.put(JahiaGWTParameters.SITE_UUID, renderContext.getSite().getIdentifier()); params.put(JahiaGWTParameters.SITE_KEY, renderContext.getSite().getSiteKey()); } } else { if (request.getParameter("site") != null) { params.put(JahiaGWTParameters.SITE_UUID, StringEscapeUtils.escapeXml(request.getParameter("site"))); } if (request.getParameter("workspace") != null) { params.put(JahiaGWTParameters.WORKSPACE, request.getParameter("workspace")); } else { params.put(JahiaGWTParameters.WORKSPACE, "default"); } } } catch (RepositoryException e) { logger.error("Error when getting site id", e); } // put live workspace url if (request.getAttribute("url") != null) { URLGenerator url = (URLGenerator) request.getAttribute("url"); params.put(JahiaGWTParameters.BASE_URL, url.getContext() + url.getBase()); params.put(JahiaGWTParameters.STUDIO_URL, url.getContext() + url.getStudio()); params.put(JahiaGWTParameters.STUDIO_VISUAL_URL, url.getContext() + url.getStudioVisual()); addLanguageSwitcherLinks(renderContext, params, url); } else { params.put(JahiaGWTParameters.BASE_URL, contextPath + Render.getRenderServletPath() + "/" + params.get("workspace") + "/" + locale.toString()); } if (SettingsBean.getInstance().isUseWebsockets()) { params.put(JahiaGWTParameters.USE_WEBSOCKETS, "true"); } String customCkeditorConfig = getCustomCKEditorConfig(request, renderContext); if (customCkeditorConfig != null) { params.put("ckeCfg", customCkeditorConfig); } // add jahia parameter dictionary buf.append("<script type=\"text/javascript\">\n"); buf.append(getJahiaGWTConfig(params)); buf.append("\n</script>\n"); addJavaScript(buf, request, renderContext); return buf.toString(); }