Package org.exoplatform.services.resources

Examples of org.exoplatform.services.resources.LocaleConfig


   }

   public void testLocaleConfigManager() throws Exception
   {
      //-------------------default locale is English-------------
      LocaleConfig locale = service_.getDefaultLocaleConfig();
      assertTrue("expect defautl locale config is found", locale != null);
      assertTrue("expect default locale is English", locale.getLocale().equals(Locale.ENGLISH));
      // --------------get a locale------------------
      locale = service_.getLocaleConfig("fr");
      assertTrue("expect locale config is found", locale != null);
      assertTrue("expect France locale is found", locale.getLocale().equals(Locale.FRENCH));

      locale = service_.getLocaleConfig("vi");
      assertTrue("expect locale config is found", locale != null);
      assertEquals("expect Viet Nam locale is found", "vi", locale.getLocale().toString());
      /*-------------------get all locale config-------------------
       * 4 preconfig locales: English, France, Arabic, Vietnamese
      **/
      Collection<LocaleConfig> locales = service_.getLocalConfigs();
      assertTrue(locales.size() == 4);
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 displayName = null;
        String language = null;
        String country = null;
        SelectItemOption<String> option;
        while (i.hasNext()) {
            LocaleConfig config = i.next();
            Locale locale = config.getLocale();

            language = locale.getLanguage();
            country = locale.getCountry();
            if (country != null && country.length() > 0) {
                language = language + "_" + country;
View Full Code Here

        String language = null;
        String country = null;
        String defaultValue = null;
        SelectItemOption<String> option;
        while (i.hasNext()) {
            LocaleConfig config = i.next();
            Locale locale = config.getLocale();

            language = locale.getLanguage();
            country = locale.getCountry();
            if (country != null && country.length() > 0) {
                language = language + "_" + country;
View Full Code Here

            editPortal.setModifiable(acl.hasEditPermission(pConfig));
        } else {
            editPortal.setModifiable(false);
        }
        LocaleConfigService localeConfigService = uiPortalApp.getApplicationComponent(LocaleConfigService.class);
        LocaleConfig localeConfig = localeConfigService.getLocaleConfig(portalConfig.getLocale());
        if (localeConfig == null) {
            localeConfig = localeConfigService.getDefaultLocaleConfig();
        }
        // TODO dang.tung - change layout when portal get language from UIPortal
        // (user and browser not support)
        // ----------------------------------------------------------------------------------------------------
        String portalAppLanguage = prContext.getLocale().getLanguage();
        OrganizationService orgService = getApplicationComponent(OrganizationService.class);
        UserProfile userProfile = orgService.getUserProfileHandler().findUserProfileByName(remoteUser);
        String userLanguage = userProfile.getUserInfoMap().get(Constants.USER_LANGUAGE);
        String browserLanguage = prContext.getRequest().getLocale().getLanguage();

        // in case: edit current portal, set skin and language for uiPortalApp
        if (uiPortal == null) {
            if (!portalAppLanguage.equals(userLanguage) && !portalAppLanguage.equals(browserLanguage)) {
                prContext.setLocale(localeConfig.getLocale());
                // editPortal.refreshNavigation(localeConfig.getLocale());
                // uiPortalApp.localizeNavigations();
            }
            uiPortalApp.setSkin(editPortal.getSkin());
        }
View Full Code Here

    private void resetOrientation(PortalRequestContext context, Locale loc) {
        ExoContainer container = context.getApplication().getApplicationServiceContainer();
        LocaleConfigService localeConfigService = (LocaleConfigService) container
                .getComponentInstanceOfType(LocaleConfigService.class);
        LocaleConfig localeConfig = localeConfigService.getLocaleConfig(LocaleContextInfo.getLocaleAsString(loc));
        if (localeConfig == null) {
            if (log.isWarnEnabled())
                log.warn("Locale changed to unsupported Locale during request processing: " + loc);
            return;
        }
        // we presume PortalRequestContext, and UIPortalApplication
        ((UIPortalApplication) context.getUIApplication()).setOrientation(localeConfig.getOrientation());
    }
View Full Code Here

                log.warn("No locale set on PortalRequestContext! Falling back to 'en'.");
            locale = Locale.ENGLISH;
        }

        String localeName = LocaleContextInfo.getLocaleAsString(locale);
        LocaleConfig localeConfig = localeConfigService.getLocaleConfig(localeName);
        if (localeConfig == null) {
            if (log.isWarnEnabled())
                log.warn("Unsupported locale set on PortalRequestContext: " + localeName + "! Falling back to 'en'.");
            localeConfig = localeConfigService.getLocaleConfig(Locale.ENGLISH.getLanguage());
        }
        setOrientation(localeConfig.getOrientation());

        // -------------------------------------------------------------------------------
        context.setUIApplication(this);

        this.all_UIPortals = new HashMap<SiteKey, UIPortal>(5);
View Full Code Here

        Locale currentLocale = Util.getPortalRequestContext().getLocale();
        SelectItemOption localeItem = null;
        List<SelectItemOption> optionsList = new ArrayList<SelectItemOption>();

        for (Object object : configService.getLocalConfigs()) {
            LocaleConfig localeConfig = (LocaleConfig) object;
            Locale locale = localeConfig.getLocale();
            String lang = locale.getLanguage();
            String country = locale.getCountry();

            ResourceBundle currentLocaleResourceBundle = getResourceBundle(currentLocale);
            ResourceBundle localeResourceBundle = getResourceBundle(locale);
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.