W3C home > Mailing lists > Public > www-validator-cvs@w3.org > November 2007

2002/css-validator/org/w3c/css/index TranslationTableGenerator.java,1.2,1.3 translations.vm,1.2,1.3

From: Olivier Thereaux via cvs-syncmail <cvsmail@w3.org>
Date: Tue, 27 Nov 2007 07:00:47 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1IwuR5-0004Fp-VV@lionel-hutz.w3.org>

Update of /sources/public/2002/css-validator/org/w3c/css/index
In directory hutz:/tmp/cvs-serv16116/org/w3c/css/index

Modified Files:
	TranslationTableGenerator.java translations.vm 
Log Message:
calculating coverage percentage.
adding thead for readability


Index: TranslationTableGenerator.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/index/TranslationTableGenerator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- TranslationTableGenerator.java	27 Nov 2007 01:44:28 -0000	1.2
+++ TranslationTableGenerator.java	27 Nov 2007 07:00:45 -0000	1.3
@@ -24,6 +24,7 @@
 import java.util.Vector;
 import java.util.Collections;
 import java.util.Comparator;
+import java.lang.Integer;
 import org.w3c.css.util.ApplContext;
 import org.w3c.css.util.Messages;
 import org.w3c.css.util.Utf8Properties;
@@ -65,7 +66,7 @@
 	 */
 	public static synchronized void generateTable() {
 		
-		String default_lang = "en", name, path, translations_table;
+		String default_lang = "en", name, path, translations_table, table_head;
 		File out_file;
 		path = TranslationTableGenerator.class.getResource("").getPath();
         try {
@@ -83,7 +84,8 @@
     		// Getting the differents languages informations (for the lang choice)
     		HashMap[] languages = new HashMap[Messages.languages_name.size()];
     		HashMap translations = new HashMap();
-            translations_table = "<table id=\"translation_summary\"><tr><th scope='col' id=\"properties\">Property</th>";
+    		HashMap translation_completeness = new HashMap();
+    		table_head ="<thead><tr><th scope='col' id=\"properties\">Property</th>";
     		for (int i = 0; i < Messages.languages_name.size(); ++i) {
     			name = String.valueOf(Messages.languages_name.get(i));
     			HashMap l = new HashMap();
@@ -91,20 +93,23 @@
     			l.put("real", ((Utf8Properties) Messages.languages.get(name)).getProperty("language_name"));
     			languages[i] = l;
     			ApplContext ac_translated = new ApplContext(name);
-    			translations.put(name,ac_translated);
     			if (!name.equals(default_lang)){
-    			    translations_table = translations_table + "<th scope=\"col\">"+l.get("real")+"</th>";
+    			    table_head=table_head+"<th>"+l.get("real")+"</th>";
                 }
+    			translations.put(name,ac_translated);
+    			translation_completeness.put(name, 0);
+		        
     		}
-    		vc.put("languages", languages);
-    		vc.put("num_languages", Messages.languages_name.size());
+    		table_head=table_head+"</thead>";
     		Vector sorted_properties_keys = new Vector(ac_default.getMsg().properties.keySet());
     		Collections.sort(sorted_properties_keys, new AlphaComparator());
             Iterator properties_iterator = sorted_properties_keys.iterator();
-    		translations_table = translations_table + "</tr>";
+    		translations_table = "<tbody>";
+    		int num_properties = 0;
     		while (properties_iterator.hasNext()) {
+    		    ++num_properties;
     		    String property_name = String.valueOf(properties_iterator.next());
-    			translations_table = translations_table + "<tr><th scope=\"row\">"+property_name;
+    			translations_table = translations_table + "<tr><th scope=\"row\" class=\"property_name\">"+property_name;
     			translations_table = translations_table+"<p>"+StringEscapeUtils.escapeHtml(ac_default.getMsg().getString(property_name))+"</p></th>";
     			for (int i = 0; i < Messages.languages_name.size(); ++i) {
     			    HashMap language = languages[i];
@@ -123,12 +128,30 @@
         			    }
         			    else {
         			        translations_table = translations_table + "<td class=\"table_translation_ok\"><span title=\""+StringEscapeUtils.escapeHtml(property_translated)+"\">✔</span></td>\n";
+        			        int completed = Integer.parseInt(translation_completeness.get(language.get("name")).toString());
+        			        ++completed;
+        			        translation_completeness.put(language.get("name"), completed);
+        			        //System.out.println(language.get("name")+": "+completed);
         			    }
         			}
                 }
                 translations_table = translations_table + "</tr>";
+                if(num_properties%12 == 0) {
+                    translations_table = translations_table+"</tbody>"+table_head+"<tbody>";
+                }
+            }
+            translations_table = translations_table + "</tbody></table>";
+            for (int i = 0; i < Messages.languages_name.size(); ++i) {
+    			name = String.valueOf(Messages.languages_name.get(i));
+    		    HashMap l = (HashMap) languages[i];
+    		    int completeness_percent = 100*Integer.parseInt(translation_completeness.get(l.get("name")).toString());
+    		    completeness_percent = completeness_percent /ac_default.getMsg().properties.size();
+    		    l.put("completeness", completeness_percent);
+    		    languages[i] = l;
     		}
-            translations_table = translations_table + "</table>";
+    		vc.put("languages", languages);
+    		vc.put("num_languages", Messages.languages_name.size());
+    		vc.put("total_properties", ac_default.getMsg().properties.size());
     	    vc.put("translations_table", translations_table);
     	    vc.put("lang", "en");
         	OutputStreamWriter aFileWriter = new OutputStreamWriter(new FileOutputStream(out_file), "UTF-8");

Index: translations.vm
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/index/translations.vm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- translations.vm	27 Nov 2007 01:44:28 -0000	1.2
+++ translations.vm	27 Nov 2007 07:00:45 -0000	1.3
@@ -6,5 +6,23 @@
 <p>Cells marked <span class='table_translation_ok'>✔</span> are translated and up-to-date. Hover above  ✔ to read the current translation for each string.</p>
 <p>You can help fill the blanks and complete the translation in <strong>your</strong> language!</p>
 </div>
+<table id="translation_summary">
+<thead><tr>
+<th scope='col' class="property_name" id="properties">Property</th>
+#foreach ( $language in $languages )
+    #set ( $name = $language.get("name") )
+	#if ($name != "en")
+	    #if ( $language.get("real") )
+	        #set ( $real =  $language.get("real") )
+	    #else
+	        #set ( $real = $language.get("name") )
+	    #end
+		#set ($completeness = $language.get("completeness") )
+		<th scope='col'>$real <br /> $completeness%</th>
+	#end
+#end
+</tr></thead>
+
+
 $translations_table
 #parse("./footer.vm")
Received on Tuesday, 27 November 2007 07:01:03 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:54:59 GMT