[gatein-commits] gatein SVN: r4079 - portal/branches/branch-r4047/webui/portal/src/main/java/org/exoplatform/portal/webui/portal.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Sep 8 02:49:13 EDT 2010


Author: ndkhoiits
Date: 2010-09-08 02:49:13 -0400 (Wed, 08 Sep 2010)
New Revision: 4079

Modified:
   portal/branches/branch-r4047/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java
Log:
GTNPORTAL-1462 Allow to change Locale of site to language having particular country

Modified: portal/branches/branch-r4047/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java
===================================================================
--- portal/branches/branch-r4047/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java	2010-09-08 06:44:10 UTC (rev 4078)
+++ portal/branches/branch-r4047/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalForm.java	2010-09-08 06:49:13 UTC (rev 4079)
@@ -171,8 +171,13 @@
 
       LocaleConfigService localeConfigService = getApplicationComponent(LocaleConfigService.class);
       LocaleConfig localeConfig = localeConfigService.getLocaleConfig(editPortal.getLocale());
-      this.<UIFormInputSet> getChildById("PortalSetting").<UIFormSelectBox> getChildById(FIELD_LOCALE).setValue(
-         localeConfig.getLanguage());
+      String lang = localeConfig.getLanguage();
+      if (localeConfig.getLocale().getCountry() != null && localeConfig.getLocale().getCountry().length() > 0)
+      {
+         lang += "_" + localeConfig.getLocale().getCountry();
+      }
+      
+      this.<UIFormInputSet> getChildById("PortalSetting").<UIFormSelectBox> getChildById(FIELD_LOCALE).setValue(lang);
       setActions(new String[]{"Save", "Close"});
    }
 
@@ -187,7 +192,6 @@
 
    private void createDefaultItem() throws Exception
    {
-      UIPortal uiPortal = Util.getUIPortal();
       LocaleConfigService localeConfigService = getApplicationComponent(LocaleConfigService.class);
       Collection<?> listLocaleConfig = localeConfigService.getLocalConfigs();
       LocaleConfig defaultLocale = localeConfigService.getDefaultLocaleConfig();
@@ -198,28 +202,27 @@
       {
          LocaleConfig localeConfig = (LocaleConfig)iterator.next();
          ResourceBundle localeResourceBundle = getResourceBundle(currentLocale);
-
-         String key = "Locale." + localeConfig.getLocale().getLanguage();
-         if (localeConfig.getLocale().getCountry() != null)
+         Locale local = localeConfig.getLocale();
+         String lang = local.getLanguage();
+         if (local.getCountry() != null && local.getCountry().length() > 0)
          {
-            key += "_" + localeConfig.getLocale().getCountry();
+            lang += "_" + local.getCountry();
          }
          
          String displayName = null;
          try
          {
+            String key = "Locale." + lang;
             String translation = localeResourceBundle.getString(key);
             displayName = translation;
          }
          catch (MissingResourceException e)
          {
-            displayName = capitalizeFirstLetter(localeConfig.getLocale().getDisplayName(currentLocale));;
+            displayName = capitalizeFirstLetter(local.getDisplayName(currentLocale));;
          }
          
-         SelectItemOption<String> option =
-            new SelectItemOption<String>(displayName, localeConfig
-               .getLanguage());
-         if (defaultLanguage.equals(localeConfig.getLanguage()))
+         SelectItemOption<String> option = new SelectItemOption<String>(displayName, lang);
+         if (defaultLanguage.equals(lang))
          {
             option.setSelected(true);
          }



More information about the gatein-commits mailing list