← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2315: Minor fix.

 

------------------------------------------------------------
revno: 2315
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-10-05 13:45:43 +0700
message:
  Minor fix.
modified:
  dhis-2/dhis-services/dhis-service-i18n/src/main/java/org/hisp/dhis/i18n/resourcebundle/DefaultResourceBundleManager.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-i18n/src/main/java/org/hisp/dhis/i18n/resourcebundle/DefaultResourceBundleManager.java'
--- dhis-2/dhis-services/dhis-service-i18n/src/main/java/org/hisp/dhis/i18n/resourcebundle/DefaultResourceBundleManager.java	2010-09-29 08:28:47 +0000
+++ dhis-2/dhis-services/dhis-service-i18n/src/main/java/org/hisp/dhis/i18n/resourcebundle/DefaultResourceBundleManager.java	2010-10-05 06:45:43 +0000
@@ -51,7 +51,8 @@
  * @author Torgeir Lorange Ostby
  * @author Pham Thi Thuy
  * @author Nguyen Dang Quang
- * @version $Id: DefaultResourceBundleManager.java 6335 2008-11-20 11:11:26Z larshelg $
+ * @version $Id: DefaultResourceBundleManager.java 6335 2008-11-20 11:11:26Z
+ *          larshelg $
  */
 public class DefaultResourceBundleManager
     implements ResourceBundleManager
@@ -174,13 +175,14 @@
 
     private Collection<Locale> getAvailableLocalesFromDir( String dirPath )
     {
-        dirPath = dirPath.replaceAll( "%20", " " );
-        File dir = new File( dirPath );    
+        dirPath = convertURLToFilePath( dirPath );
+
+        File dir = new File( dirPath );
         Set<Locale> availableLocales = new HashSet<Locale>();
         File[] files = dir.listFiles( new FilenameFilter()
         {
             public boolean accept( File dir, String name )
-            {             
+            {
                 return name.startsWith( globalResourceBundleName ) && name.endsWith( EXT_RESOURCE_BUNDLE );
             }
         } );
@@ -220,4 +222,24 @@
 
         return LocaleManager.DHIS_STANDARD_LOCALE;
     }
+
+    // -------------------------------------------------------------------------
+    // Support method
+    // -------------------------------------------------------------------------
+
+    private String convertURLToFilePath( String url )
+    {
+        return url.replaceAll( "%20", " " )
+                .replaceAll( "%21", "!" ).replaceAll( "%22", "\"" )
+                .replaceAll( "%23", "#" ).replaceAll( "%24", "$" )
+                .replaceAll( "%25", "%" ).replaceAll( "%26", "&" )
+                .replaceAll( "%27", "\'").replaceAll( "%28", "(" )
+                .replaceAll( "%29", ")" ).replaceAll( "%2a", "*" )
+                .replaceAll( "%2b", "+" ).replaceAll( "%2c", "," )
+                .replaceAll( "%2d", "-" ).replaceAll( "%2e", "." )
+                .replaceAll( "%2f", "/" ).replaceAll( "%3a", ":" )
+                .replaceAll( "%3b", ";" ).replaceAll( "%3c", "<" )
+                .replaceAll( "%3d", "=" ).replaceAll( "%3e", ">" )
+                .replaceAll( "%3f", "?" ).replaceAll( "%40", "@" );
+    }
 }