Package org.exoplatform.services.resources

Examples of org.exoplatform.services.resources.LocaleConfig


    /**
     * @param lang a locale language
     * @return The LocalConfig
     */
    public LocaleConfig getLocaleConfig(String lang) {
        LocaleConfig config = configs_.get(lang);
        if (config != null)
            return config;
        return defaultConfig_;
    }
View Full Code Here


        Document document = parser.parse(is);
        NodeList nodes = document.getElementsByTagName("locale-config");
        for (int i = 0; i < nodes.getLength(); i++) {
            Node node = nodes.item(i);
            NodeList children = node.getChildNodes();
            LocaleConfig config = new LocaleConfigImpl();
            for (int j = 0; j < children.getLength(); j++) {
                Node element = children.item(j);
                if ("locale".equals(element.getNodeName())) {
                    config.setLocale(element.getFirstChild().getNodeValue());
                } else if ("output-encoding".equals(element.getNodeName())) {
                    config.setOutputEncoding(element.getFirstChild().getNodeValue());
                } else if ("input-encoding".equals(element.getNodeName())) {
                    config.setInputEncoding(element.getFirstChild().getNodeValue());
                } else if ("description".equals(element.getNodeName())) {
                    config.setDescription(element.getFirstChild().getNodeValue());
                } else if ("orientation".equals(element.getNodeName())) {
                    String s = element.getFirstChild().getNodeValue();
                    Orientation orientation = orientations.get(s);
                    if (orientation == null) {
                        log.error("Wrong orientation value " + s);
                    } else {
                        config.setOrientation(orientation);
                    }
                }
            }

            //
            if (config.getOrientation() == null) {
                log.debug("No orientation found on the locale config, use the LT default");
                config.setOrientation(Orientation.LT);
            }

            //
            log.debug("Added locale config " + config + " to the set of locale configs");

            //
            String country = config.getLocale().getCountry();
            if (country != null && country.length() > 0) {
                configs_.put(config.getLanguage() + "_" + country, config);
            } else {
                configs_.put(config.getLanguage(), config);
            }
            if (i == 0)
                defaultConfig_ = config;
        }

        //
        if (PropertyManager.isDevelopping()) {
            LocaleConfig magicConfig = new LocaleConfigImpl();
            magicConfig.setLocale(IdentityResourceBundle.MAGIC_LOCALE);
            magicConfig.setDescription("Magic locale");
            magicConfig.setInputEncoding("UTF-8");
            magicConfig.setOutputEncoding("UTF-8");
            magicConfig.setDescription("Default configuration for the debugging locale");
            magicConfig.setOrientation(Orientation.LT);
            configs_.put(magicConfig.getLanguage(), magicConfig);
            log.debug("Added magic locale for debugging bundle usage at runtime");
        }
    }
View Full Code Here

            // String defaultLang =
            // localeService_.getDefaultLocaleConfig().getLanguage();
            Locale defaultLocale = localeService_.getDefaultLocaleConfig().getLocale();

            for (Iterator<LocaleConfig> iter = localeConfigs.iterator(); iter.hasNext();) {
                LocaleConfig localeConfig = iter.next();
                // String language = localeConfig.getLanguage();
                // String content = getResourceBundleContent(name, language,
                // defaultLang, cl);
                Locale locale = localeConfig.getLocale();
                String language = locale.getLanguage();
                String country = locale.getCountry();

                String content = getResourceBundleContent(name, locale, defaultLocale, cl);
                if (content != null) {
View Full Code Here

      {
         Collection<LocaleConfig> localeConfigs = localeService_.getLocalConfigs();
         String defaultLang = localeService_.getDefaultLocaleConfig().getLanguage();
         for (Iterator<LocaleConfig> iter = localeConfigs.iterator(); iter.hasNext();)
         {
            LocaleConfig localeConfig = iter.next();
            String language = localeConfig.getLanguage();
            String content = getResourceBundleContent(name, language, defaultLang, cl);
            if (content != null)
            {
               // save the content
               ResourceBundleData data = new ResourceBundleData();
View Full Code Here

    * @param lang a locale language
    * @return The LocalConfig
    */
   public LocaleConfig getLocaleConfig(String lang)
   {
      LocaleConfig config = configs_.get(lang);
      if (config != null)
         return config;
      return defaultConfig_;
   }
View Full Code Here

      NodeList nodes = document.getElementsByTagName("locale-config");
      for (int i = 0; i < nodes.getLength(); i++)
      {
         Node node = nodes.item(i);
         NodeList children = node.getChildNodes();
         LocaleConfig config = new LocaleConfigImpl();
         for (int j = 0; j < children.getLength(); j++)
         {
            Node element = children.item(j);
            if ("locale".equals(element.getNodeName()))
            {
               config.setLocale(element.getFirstChild().getNodeValue());
            }
            else if ("output-encoding".equals(element.getNodeName()))
            {
               config.setOutputEncoding(element.getFirstChild().getNodeValue());
            }
            else if ("input-encoding".equals(element.getNodeName()))
            {
               config.setInputEncoding(element.getFirstChild().getNodeValue());
            }
            else if ("description".equals(element.getNodeName()))
            {
               config.setDescription(element.getFirstChild().getNodeValue());
            }
            else if ("orientation".equals(element.getNodeName()))
            {
               String s = element.getFirstChild().getNodeValue();
               Orientation orientation = orientations.get(s);
               if (orientation == null)
               {
                  log.error("Wrong orientation value " + s);
               }
               else
               {
                  config.setOrientation(orientation);
               }
            }
         }

         //
         if (config.getOrientation() == null)
         {
            log.debug("No orientation found on the locale config, use the LT default");
            config.setOrientation(Orientation.LT);
         }

         //
         log.debug("Added locale config " + config + " to the set of locale configs");

         //
         configs_.put(config.getLanguage(), config);
         if (i == 0)
            defaultConfig_ = config;
      }

      //
      if (PropertyManager.isDevelopping())
      {
         LocaleConfig magicConfig = new LocaleConfigImpl();
         magicConfig.setLocale(IdentityResourceBundle.MAGIC_LOCALE);
         magicConfig.setDescription("Magic locale");
         magicConfig.setInputEncoding("UTF-8");
         magicConfig.setOutputEncoding("UTF-8");
         magicConfig.setDescription("Default configuration for the debugging locale");
         magicConfig.setOrientation(Orientation.LT);
         configs_.put(magicConfig.getLanguage(), magicConfig);
         log.debug("Added magic locale for debugging bundle usage at runtime");
      }
   }
View Full Code Here

         // localeService_.getDefaultLocaleConfig().getLanguage();
         Locale defaultLocale = localeService_.getDefaultLocaleConfig().getLocale();

         for (Iterator<LocaleConfig> iter = localeConfigs.iterator(); iter.hasNext();)
         {
            LocaleConfig localeConfig = iter.next();
            // String language = localeConfig.getLanguage();
            // String content = getResourceBundleContent(name, language,
            // defaultLang, cl);
            Locale locale = localeConfig.getLocale();
            String language = locale.getLanguage();
            String country = locale.getCountry();

            String content = getResourceBundleContent(name, locale, defaultLocale, cl);
            if (content != null)
View Full Code Here

    *           a locale language
    * @return The LocalConfig
    */
   public LocaleConfig getLocaleConfig(String lang)
   {
      LocaleConfig config = configs_.get(lang);
      if (config != null)
         return config;
      return defaultConfig_;
   }
View Full Code Here

      NodeList nodes = document.getElementsByTagName("locale-config");
      for (int i = 0; i < nodes.getLength(); i++)
      {
         Node node = nodes.item(i);
         NodeList children = node.getChildNodes();
         LocaleConfig config = new LocaleConfigImpl();
         for (int j = 0; j < children.getLength(); j++)
         {
            Node element = children.item(j);
            if ("locale".equals(element.getNodeName()))
            {
               config.setLocale(element.getFirstChild().getNodeValue());
            }
            else if ("output-encoding".equals(element.getNodeName()))
            {
               config.setOutputEncoding(element.getFirstChild().getNodeValue());
            }
            else if ("input-encoding".equals(element.getNodeName()))
            {
               config.setInputEncoding(element.getFirstChild().getNodeValue());
            }
            else if ("description".equals(element.getNodeName()))
            {
               config.setDescription(element.getFirstChild().getNodeValue());
            }
            else if ("orientation".equals(element.getNodeName()))
            {
               String s = element.getFirstChild().getNodeValue();
               Orientation orientation = orientations.get(s);
               if (orientation == null)
               {
                  log.error("Wrong orientation value " + s);
               }
               else
               {
                  config.setOrientation(orientation);
               }
            }
         }

         //
         if (config.getOrientation() == null)
         {
            log.debug("No orientation found on the locale config, use the LT default");
            config.setOrientation(Orientation.LT);
         }

         //
         log.debug("Added locale config " + config + " to the set of locale configs");

         //
         String country = config.getLocale().getCountry();
         if (country != null && country.length() > 0)
         {
            configs_.put(config.getLanguage() + "_" + country, config);
         }
         else
         {
            configs_.put(config.getLanguage(), config);
         }
         if (i == 0)
            defaultConfig_ = config;
      }

      //
      if (PropertyManager.isDevelopping())
      {
         LocaleConfig magicConfig = new LocaleConfigImpl();
         magicConfig.setLocale(IdentityResourceBundle.MAGIC_LOCALE);
         magicConfig.setDescription("Magic locale");
         magicConfig.setInputEncoding("UTF-8");
         magicConfig.setOutputEncoding("UTF-8");
         magicConfig.setDescription("Default configuration for the debugging locale");
         magicConfig.setOrientation(Orientation.LT);
         configs_.put(magicConfig.getLanguage(), magicConfig);
         log.debug("Added magic locale for debugging bundle usage at runtime");
      }
   }
View Full Code Here

      String language = null;
      String country = null;
      SelectItemOption<String> option;
      while (i.hasNext())
      {
         LocaleConfig config = i.next();
         Locale locale = config.getLocale();
         displayName = locale.getDisplayName(currentLocale);
         language = locale.getLanguage();
         country = locale.getCountry();
         if (country != null && country.length() > 0)
         {
            displayLanguage = displayName + " (" + locale.getDisplayCountry(currentLocale) + ")";
         }
         else
         {
            displayLanguage = displayName;
         }
         option = new SelectItemOption<String>(displayLanguage, language, displayName);
         if (language.equals(selectedLang))
         {
            option.setSelected(true);
         }
         if (config.getLanguage().equals("en"))
         {
            lang.add(0, option);
            continue;
         }
         lang.add(option);
View Full Code Here

TOP

Related Classes of org.exoplatform.services.resources.LocaleConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.