/** * Reads the locale for the given resource.<p> * * @param res the locale for the resource */ private void readLocale(CmsResource res) { Locale locale = OpenCms.getLocaleManager().getDefaultLocale(m_cms, res); m_localeCache.put(res, locale); }
/** * Returns the configured default locales for the content of the given resource.<p> * * @param cms the cms context * @param resource the resource path to get the default locales for * * @return the default locales of the resource */ protected List<Locale> getLocalesForResource(CmsObject cms, String resource) { List<Locale> locales = OpenCms.getLocaleManager().getDefaultLocales(cms, resource); if ((locales == null) || locales.isEmpty()) { locales = OpenCms.getLocaleManager().getAvailableLocales(); } return locales; }
/** * Creates a value string for the HTTP Accept-Language header based on the default localed.<p> * * @return value string for the HTTP Accept-Language */ public static String createLanguageHeader() { String header; // get the default accept-language header value List<Locale> defaultLocales = OpenCms.getLocaleManager().getDefaultLocales(); Iterator<Locale> i = defaultLocales.iterator(); header = ""; while (i.hasNext()) { Locale loc = i.next(); header += loc.getLanguage() + ", "; } header = header.substring(0, header.length() - 2); return header; }
/** * 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 */ 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; }
/** * @see org.apache.commons.collections.Transformer#transform(java.lang.Object) */ public Object transform(Object input) { List<Locale> result; // read the available locales result = OpenCms.getLocaleManager().getAvailableLocales(getCmsObject(), String.valueOf(input)); return result; } }
/** * Collects all locales possibly used in the system.<p> * * @return the collection of all locales */ private static Collection<Locale> getAllLocales() { Set<Locale> result = new HashSet<Locale>(); result.addAll(OpenCms.getWorkplaceManager().getLocales()); result.addAll(OpenCms.getLocaleManager().getAvailableLocales()); return result; }
/** * Returns the language locale for the given resource in this index.<p> * * @param cms the current OpenCms user context * @param resource the resource to check * @param availableLocales a list of locales supported by the resource * * @return the language locale for the given resource in this index */ public Locale getLocaleForResource(CmsObject cms, CmsResource resource, List<Locale> availableLocales) { Locale result; List<Locale> defaultLocales = OpenCms.getLocaleManager().getDefaultLocales(cms, resource); List<Locale> locales = availableLocales; if ((locales == null) || (locales.size() == 0)) { locales = defaultLocales; } result = OpenCms.getLocaleManager().getBestMatchingLocale(getLocale(), defaultLocales, locales); return result; }
/** * Returns the selector widget options to build a Locale selector widget.<p> * * @return the selector widget options to build a Locale selector widget */ public List getLocaleConfigOptions() { List result = new ArrayList(); List locales = OpenCms.getLocaleManager().getAvailableLocales(); Iterator i = locales.iterator(); while (i.hasNext()) { Locale locale = (Locale)i.next(); String localeStr = locale.toString(); String localeDisplayStr = locale.getDisplayName(getLocale()); result.add(new CmsSelectWidgetOption(localeStr, false, localeDisplayStr)); } return result; }
/** * Gets the locale to use for the given resource.<p> * * @param resource the resource * @param propertyList the properties of the resource * * @return the locale to use for the given resource */ private Locale getLocale(CmsResource resource, List<CmsProperty> propertyList) { return OpenCms.getLocaleManager().getDefaultLocale(m_guestCms, m_guestCms.getSitePath(resource)); }
/** * Returns a list with the possible <code>{@link Locale}</code> selections based on the OpenCms configuration. * <p> * * @return a list with the possible <code>{@link Locale}</code> selections based on the OpenCms configuration. */ private List<CmsSelectWidgetOption> getLanguageSelections() { List<CmsSelectWidgetOption> result = new LinkedList<CmsSelectWidgetOption>(); List<Locale> sysLocales = OpenCms.getLocaleManager().getAvailableLocales(); CmsSelectWidgetOption option; boolean first = true; for (Locale locale : sysLocales) { option = new CmsSelectWidgetOption(locale.toString(), first, locale.getDisplayName(getLocale())); first = false; result.add(option); } return result; }
/** * Returns the appropriate locale for the given destination.<p> * * @param destination the destination path (parent must exist) * @param properties the properties to check at first * * @return the locale */ protected Locale getLocale(String destination, List<CmsProperty> properties) { String localeName = CmsProperty.get(CmsPropertyDefinition.PROPERTY_LOCALE, properties).getValue(); if (localeName != null) { // locale was already set on the files properties return OpenCms.getLocaleManager().getAvailableLocales(localeName).get(0); } // locale not set in properties, read default locales return OpenCms.getLocaleManager().getDefaultLocales(m_cms, CmsResource.getParentFolder(destination)).get(0); }
/** * Determines if the element language selector is shown dependent on the available Locales.<p> * * @return true, if more than one Locale is available, otherwise false */ public boolean showElementLanguageSelector() { List<Locale> locales = OpenCms.getLocaleManager().getAvailableLocales(getCms(), getParamResource()); if ((locales == null) || (locales.size() < 2)) { // for less than two available locales, do not create language selector return false; } return true; }
/** * Determines if the element language selector is shown dependent on the available Locales.<p> * * @return true, if more than one Locale is available, otherwise false */ public boolean showElementLanguageSelector() { List locales = OpenCms.getLocaleManager().getAvailableLocales(getCms(), getParamResource()); if ((locales == null) || (locales.size() < 2)) { // for less than two available locales, do not create language selector return false; } return true; }
/** * Returns the appropriate locale for the given destination.<p> * * @param destination the destination path (parent must exist) * @param properties the properties to check at first * * @return the locale */ protected Locale getLocale(String destination, List properties) { String localeName = CmsProperty.get(CmsPropertyDefinition.PROPERTY_LOCALE, properties).getValue(); if (localeName != null) { // locale was already set on the files properties return OpenCms.getLocaleManager().getAvailableLocales(localeName).get(0); } // locale not set in properties, read default locales return OpenCms.getLocaleManager().getDefaultLocales(m_cms, CmsResource.getParentFolder(destination)).get(0); }
/** * Returns the locales available for the currently requested URI. * * @return the locales available for the currently requested URI. */ public List<Locale> getAvailableLocales() { return OpenCms.getLocaleManager().getAvailableLocales(m_cms, getRequestContext().getUri()); }
/** * Initializes the element language for the first call of the editor.<p> */ protected void initElementLanguage() { // get the default locale for the resource List<Locale> locales = OpenCms.getLocaleManager().getDefaultLocales(getCms(), getParamResource()); Locale locale = locales.get(0); locale = ensureLocale(locale); setParamElementlanguage(locale.toString()); }
public Locale getComparisonLocale() { return OpenCms.getLocaleManager().getDefaultLocale(context.getCms(), getRoot()); }
public Locale getRootLocale() { return OpenCms.getLocaleManager().getDefaultLocale(context.getCms(), getRoot()); }
/** * Checks whether single locale detail containers should be used for the given site root.<p> * * @param siteRoot the site root to check * * @return <code>true</code> if single locale detail containers should be used for the given site root */ public static boolean useSingleLocaleDetailContainers(String siteRoot) { boolean result = false; if ((siteRoot != null) && (OpenCms.getLocaleManager().getLocaleHandler() instanceof CmsSingleTreeLocaleHandler)) { CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(siteRoot); result = (site != null) && CmsSite.LocalizationMode.singleTree.equals(site.getLocalizationMode()); } return result; }
/** * @see org.opencms.gwt.shared.rpc.I_CmsVfsService#loadLinkInfo(org.opencms.util.CmsUUID) */ public CmsExternalLinkInfoBean loadLinkInfo(CmsUUID structureId) throws CmsRpcException { CmsExternalLinkInfoBean info = new CmsExternalLinkInfoBean(); CmsObject cms = getCmsObject(); try { CmsResource linkResource = cms.readResource(structureId, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED); addPageInfo(cms, linkResource, info); CmsFile linkFile = cms.readFile(linkResource); OpenCms.getLocaleManager(); String link = new String(linkFile.getContents(), CmsLocaleManager.getResourceEncoding(cms, linkResource)); info.setLink(link); info.setSitePath(cms.getSitePath(linkResource)); } catch (Exception e) { error(e); } return info; }