jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mets...@apache.org
Subject svn commit: r1490010 - in /incubator/jspwiki/trunk: ChangeLog jspwiki-war/pom.xml jspwiki-war/src/main/java/org/apache/wiki/Release.java jspwiki-war/src/main/java/org/apache/wiki/ui/TemplateManager.java
Date Wed, 05 Jun 2013 19:22:08 GMT
Author: metskem
Date: Wed Jun  5 19:22:08 2013
New Revision: 1490010

URL: http://svn.apache.org/r1490010
Log:
2013-06-05  Harry Metske (metskem@apache.org)

       * 2.10.0-svn-5

       * JSPWIKI-779: Refactor TemplateManager#listLanguages() to get rid of copying
         default.properties to default_en.properties

Modified:
    incubator/jspwiki/trunk/ChangeLog
    incubator/jspwiki/trunk/jspwiki-war/pom.xml
    incubator/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/Release.java
    incubator/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/ui/TemplateManager.java

Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=1490010&r1=1490009&r2=1490010&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Wed Jun  5 19:22:08 2013
@@ -1,3 +1,10 @@
+2013-06-05  Harry Metske (metskem@apache.org)
+
+       * 2.10.0-svn-5
+
+       * JSPWIKI-779: Refactor TemplateManager#listLanguages() to get rid of copying
+         default.properties to default_en.properties
+
 2013-06-03  Glen Mazza (gmazza AT apache DOT org)
 
        * 2.10.0-svn-4

Modified: incubator/jspwiki/trunk/jspwiki-war/pom.xml
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/jspwiki-war/pom.xml?rev=1490010&r1=1490009&r2=1490010&view=diff
==============================================================================
--- incubator/jspwiki/trunk/jspwiki-war/pom.xml (original)
+++ incubator/jspwiki/trunk/jspwiki-war/pom.xml Wed Jun  5 19:22:08 2013
@@ -228,14 +228,6 @@
             <id>create_files</id>
             <configuration>
               <target>
-                <!-- Creating a specific _en file presently needed just so that "English"
will appear as an option on 
-                   the User Preferences page, language option (and similar issues).  FIXME:
change JSP code  
-                   so this is no longer necessary.
-                -->
-                <copy file="src/main/resources/CoreResources.properties" tofile="target/classes/CoreResources_en.properties"/>
-                <copy file="src/main/resources/templates/default.properties" tofile="target/classes/templates/default_en.properties"/>
-                <copy file="src/main/resources/plugin/PluginResources.properties" tofile="target/classes/plugin/PluginResources_en.properties"/>
-
                 <!-- Create web.xml files for testing -->
                 <copy file="src/main/webapp/WEB-INF/web.xml" tofile="target/test-classes/WEB-INF/web.xml"
/>
 

Modified: incubator/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/Release.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/Release.java?rev=1490010&r1=1490009&r2=1490010&view=diff
==============================================================================
--- incubator/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/Release.java Wed Jun
 5 19:22:08 2013
@@ -75,7 +75,7 @@ public final class Release
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "4";
+    public static final String     BUILD         = "5";
     
     /**
      *  This is the generic version string you should use

Modified: incubator/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/ui/TemplateManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/ui/TemplateManager.java?rev=1490010&r1=1490009&r2=1490010&view=diff
==============================================================================
--- incubator/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/ui/TemplateManager.java
(original)
+++ incubator/jspwiki/trunk/jspwiki-war/src/main/java/org/apache/wiki/ui/TemplateManager.java
Wed Jun  5 19:22:08 2013
@@ -38,7 +38,6 @@ import org.apache.wiki.modules.ModuleMan
 import org.apache.wiki.preferences.Preferences;
 import org.apache.wiki.preferences.Preferences.TimeFormat;
 import org.apache.wiki.util.ClassUtil;
-
 /**
  *  This class takes care of managing JSPWiki templates.  This class also provides
  *  the ResourceRequest mechanism.
@@ -91,6 +90,11 @@ public class TemplateManager
 
     public static final String I18NRESOURCE_SUFFIX = ".properties";
 
+    /** The default (en) RESOURCE name and id. */
+
+    public static final String I18NRESOURCE_EN = "templates/default.properties";
+    public static final String I18NRESOURCE_EN_ID = "en";
+
     /** I18N string to mark the default locale */
 
     public static final String I18NDEFAULT_LOCALE = "prefs.user.language.default";
@@ -413,7 +417,9 @@ public class TemplateManager
     }
 
     /**
-     * List all installed i18n language properties
+     * List all installed i18n language properties by classpath searching for files like
:
+     *    templates/default_*.properties
+     *    templates/default.properties
      * 
      * @param pageContext
      * @return map of installed Languages
@@ -423,12 +429,17 @@ public class TemplateManager
     {
         Map< String, String > resultMap = new LinkedHashMap< String, String >();
         String clientLanguage = ((HttpServletRequest) pageContext.getRequest()).getLocale().toString();
-        
+
         List< String > entries = ClassUtil.classpathEntriesUnder( DIRECTORY );
         for( String name : entries ) {
-            if ( name.startsWith( I18NRESOURCE_PREFIX ) && name.endsWith( I18NRESOURCE_SUFFIX
) )
+            if ( name.equals( I18NRESOURCE_EN ) ||
+                    (name.startsWith( I18NRESOURCE_PREFIX ) && name.endsWith( I18NRESOURCE_SUFFIX
) ) )
             {
-                name = name.substring(I18NRESOURCE_PREFIX.length(), name.lastIndexOf(I18NRESOURCE_SUFFIX));
+                if (name.equals( I18NRESOURCE_EN )) {
+                    name = I18NRESOURCE_EN_ID;
+                }    else {
+                    name = name.substring(I18NRESOURCE_PREFIX.length(), name.lastIndexOf(I18NRESOURCE_SUFFIX));
+                }
                 Locale locale = new Locale(name.substring(0, 2), ((name.indexOf("_") == -1)
? "" : name.substring(3, 5)));
                 String defaultLanguage = "";
                 if (clientLanguage.startsWith(name))
@@ -438,7 +449,7 @@ public class TemplateManager
                 resultMap.put(name, locale.getDisplayName(locale) + " " + defaultLanguage);
             }
         }
-        
+
         return resultMap;
     }
 
@@ -640,10 +651,10 @@ public class TemplateManager
 
     /**
      *  Extract all i18n strings in the javascript domain. (javascript.*)
-     *  Returns a javascript snippet which defines the LoacalizedStings array.
+     *  Returns a javascript snippet which defines the LocalizedStings array.
      *
-     *  @param wiki context
-     *  @return Javascript snippet which defines the LocaliedStrings array
+     *  @param context the {@link WikiContext}
+     *  @return Javascript snippet which defines the LocalizedStrings array
      *  @since 2.5.108
      */
     private static String getJSLocalizedStrings( WikiContext context )



Mime
View raw message