You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by aj...@apache.org on 2008/02/13 07:27:05 UTC

svn commit: r627274 - in /incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/tests: MissingTranslations.java SamplePlugin2.java

Author: ajaquith
Date: Tue Feb 12 22:27:04 2008
New Revision: 627274

URL: http://svn.apache.org/viewvc?rev=627274&view=rev
Log: (empty)

Added:
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/tests/MissingTranslations.java
    incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/tests/SamplePlugin2.java

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/tests/MissingTranslations.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/tests/MissingTranslations.java?rev=627274&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/tests/MissingTranslations.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/tests/MissingTranslations.java Tue Feb 12 22:27:04 2008
@@ -0,0 +1,70 @@
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.*;
+
+/**
+ * Simple utility that shows you a sorted list of properties
+ * that are missing in a i18n file 
+ * (as diff from the default en properties). 
+ * 
+ * @author Christoph Sauer
+ *
+ */
+public class MissingTranslations 
+{
+
+    // Change this to your settings...
+    static String base = "C:/workspace/JSPWiki HEAD"; 
+    static String suffix = "de_DE";
+    
+    public static void main(String[] args) throws IOException
+    {
+        diff ("/etc/i18n/CoreResources.properties", 
+              "/etc/i18n/CoreResources_" + suffix + ".properties");
+
+        diff ("/etc/i18n/templates/default.properties", 
+              "/etc/i18n/templates/default_" + suffix + ".properties");
+
+        diff ("/src/com/ecyrd/jspwiki/plugin/PluginResources.properties", 
+              "/src/com/ecyrd/jspwiki/plugin/PluginResources_" + suffix + ".properties");
+    }   
+    
+    public static void diff(String en, String other) throws FileNotFoundException, IOException {
+
+        //Standard Properties
+        Properties p = new Properties();
+        p.load( new FileInputStream(new File(base + en)) );
+
+        Properties p2 = new Properties();
+        p2.load( new FileInputStream(new File(base + other)) );
+
+        System.out.println("Missing Properties in " + other + ":");
+        System.out.println("------------------------------------");
+        Iterator iter = sortedNames(p).iterator();
+        while(iter.hasNext()) 
+        {
+            String name = (String)iter.next();
+            String value = p.getProperty(name);
+            
+            if (p2.get(name) == null) {
+                System.out.println(name + " = " + value);
+            }
+        }
+        System.out.println("");
+    }
+    
+    private static List sortedNames(Properties p)
+    {
+        List list = new ArrayList();
+        Enumeration iter = p.propertyNames();
+        while(iter.hasMoreElements()) 
+        {
+            list.add(iter.nextElement());
+        }        
+        
+        Collections.sort(list);
+        return list;
+    }
+}
\ No newline at end of file

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/tests/SamplePlugin2.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/tests/SamplePlugin2.java?rev=627274&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/tests/SamplePlugin2.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/tests/SamplePlugin2.java Tue Feb 12 22:27:04 2008
@@ -0,0 +1,26 @@
+import com.ecyrd.jspwiki.*;
+import com.ecyrd.jspwiki.plugin.*;
+import java.util.*;
+
+/**
+ *  Implements a simple plugin that just returns its text.
+ *  <P>
+ *  Parameters: text - text to return.
+ *
+ *  @author Janne Jalkanen
+ */
+public class SamplePlugin2
+    implements WikiPlugin
+{
+    public void initialize( WikiEngine engine )
+        throws PluginException
+    {
+    }
+
+    public String execute( WikiContext context, Map params )
+        throws PluginException
+    {
+        return (String)params.get("text");
+    }
+
+}