- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Tue, 06 Sep 2011 14:40:32 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/index In directory hutz:/tmp/cvs-serv8408 Modified Files: translations.vm TranslationTableGenerator.java Log Message: added US-english version of the language name in title attributes on language rows Index: TranslationTableGenerator.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/index/TranslationTableGenerator.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- TranslationTableGenerator.java 24 Feb 2009 22:44:49 -0000 1.10 +++ TranslationTableGenerator.java 6 Sep 2011 14:40:30 -0000 1.11 @@ -6,6 +6,16 @@ */ package org.w3c.css.index; +import org.apache.commons.lang.StringEscapeUtils; +import org.apache.velocity.Template; +import org.apache.velocity.VelocityContext; +import org.apache.velocity.app.Velocity; +import org.apache.velocity.exception.MethodInvocationException; +import org.apache.velocity.exception.ParseErrorException; +import org.apache.velocity.exception.ResourceNotFoundException; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.Messages; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -13,36 +23,23 @@ import java.net.URI; import java.net.URISyntaxException; import java.text.SimpleDateFormat; -import java.util.Date; - -import org.apache.velocity.Template; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.Velocity; -import org.apache.velocity.exception.MethodInvocationException; -import org.apache.velocity.exception.ParseErrorException; -import org.apache.velocity.exception.ResourceNotFoundException; -import org.apache.commons.lang.StringEscapeUtils; import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Vector; import java.util.Collections; import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Locale; import java.util.Set; -import java.lang.Integer; -import org.w3c.css.util.ApplContext; -import org.w3c.css.util.Messages; -import org.w3c.css.util.Utf8Properties; +import java.util.Vector; /** * @author olivier Thereaux <ot@w3.org> for W3C - * - * */ class AlphaComparator implements Comparator<String> { public int compare(String s1, String s2) { - return s1.compareToIgnoreCase(s2); + return s1.compareToIgnoreCase(s2); } } @@ -55,133 +52,148 @@ private static String html_files_path = "../../../../"; private static boolean done = false; private static String template_name = "translations.vm"; - + /** * @param args */ public static void main(String[] args) { - TranslationTableGenerator.generateTable(); + TranslationTableGenerator.generateTable(); } /** * This method generates the index in every possible language we have the translation + * * @see org.w3c.css.util.Messages */ public static synchronized void generateTable() { - - String default_lang = "en"; - String name, path; - StringBuilder table_head = new StringBuilder(); - StringBuilder translations_table = new StringBuilder(); - File out_file; - path = TranslationTableGenerator.class.getResource("").getPath(); + + String default_lang = "en"; + String name, path; + StringBuilder table_head = new StringBuilder(); + StringBuilder translations_table = new StringBuilder(); + File out_file; + path = TranslationTableGenerator.class.getResource("").getPath(); try { - path = new URI(path).getPath(); - Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path); - Velocity.addProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path + "../css/"); - Velocity.setProperty(Velocity.RUNTIME_LOG, - "velocity-" + new SimpleDateFormat("yyyy-MM-dd_HHmm").format(new Date()) + ".log"); - - Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.AvalonLogChute"); - Velocity.init(); - - Template tpl = Velocity.getTemplate(template_name, "UTF-8"); - out_file = new File(path + html_files_path + "translations.html"); - - ApplContext ac_default= new ApplContext(default_lang); - // Getting the differents languages informations (for the lang choice) - ArrayList<HashMap<String,String>> languages; - languages = new ArrayList<HashMap<String,String>>(Messages.languages_name.size()); - HashMap<String,ApplContext> translations = new HashMap<String,ApplContext>(); - HashMap<String,Integer> translation_completeness = new HashMap<String,Integer>(); - table_head.append("<tr><th scope='col'>Property</th>"); - for (int i = 0; i < Messages.languages_name.size(); ++i) { - name = String.valueOf(Messages.languages_name.get(i)); - HashMap<String,String> l = new HashMap<String,String>(); - l.put("name", name); - l.put("real", ((Utf8Properties) Messages.languages.get(name)).getProperty("language_name")); - languages.add(i, l); - ApplContext ac_translated = new ApplContext(name); - if (!name.equals(default_lang)) { - table_head.append("<th>").append(l.get("real")).append("</th>"); + path = new URI(path).getPath(); + Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path); + Velocity.addProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path + "../css/"); + Velocity.setProperty(Velocity.RUNTIME_LOG, + "velocity-" + new SimpleDateFormat("yyyy-MM-dd_HHmm").format(new Date()) + ".log"); + + Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.AvalonLogChute"); + Velocity.init(); + + Template tpl = Velocity.getTemplate(template_name, "UTF-8"); + out_file = new File(path + html_files_path + "translations.html"); + + ApplContext ac_default = new ApplContext(default_lang); + // Getting the differents languages informations (for the lang choice) + ArrayList<HashMap<String, String>> languages; + languages = new ArrayList<HashMap<String, String>>(Messages.languages_name.size()); + HashMap<String, ApplContext> translations = new HashMap<String, ApplContext>(); + HashMap<String, Integer> translation_completeness = new HashMap<String, Integer>(); + table_head.append("<tr><th scope='col'>Property</th>"); + for (int i = 0; i < Messages.languages_name.size(); ++i) { + name = String.valueOf(Messages.languages_name.get(i)); + HashMap<String, String> l = new HashMap<String, String>(); + l.put("name", name); + l.put("real", (Messages.languages.get(name)).getProperty("language_name")); + languages.add(i, l); + ApplContext ac_translated = new ApplContext(name); + if (!name.equals(default_lang)) { + Locale locale; + String engName; + int hy = name.indexOf("-"); + if (hy > 0) { + String m = name.substring(0, hy); + String s = name.substring(hy + 1); + locale = new Locale(m, s, ""); + } else { + locale = new Locale(name); + } + engName = locale.getDisplayName(Locale.US); + table_head.append("<th title=\"").append(engName); + table_head.append("\">"); + table_head.append(l.get("real")).append("</th>"); + l.put("engname", engName); } - translations.put(name,ac_translated); - translation_completeness.put(name, 0); - - } - table_head.append("</tr>"); - Vector<String> sorted_properties_keys; - Set properties_keyset = ac_default.getMsg().properties.keySet(); - sorted_properties_keys = new Vector<String>(properties_keyset); - Collections.sort(sorted_properties_keys, new AlphaComparator()); + translations.put(name, ac_translated); + translation_completeness.put(name, 0); + + } + table_head.append("</tr>"); + Vector<String> sorted_properties_keys; + Set properties_keyset = ac_default.getMsg().properties.keySet(); + sorted_properties_keys = new Vector<String>(properties_keyset); + Collections.sort(sorted_properties_keys, new AlphaComparator()); Iterator properties_iterator = sorted_properties_keys.iterator(); - translations_table.append("<tbody>"); - int num_properties = 0; - while (properties_iterator.hasNext()) { - ++num_properties; - String property_name = String.valueOf(properties_iterator.next()); - translations_table.append("<tr><th scope=\"row\" class=\"property_name\">").append(property_name); - translations_table.append("<p>").append(StringEscapeUtils.escapeHtml(ac_default.getMsg().getString(property_name))); - translations_table.append("</p></th>"); - for (int i = 0; i < Messages.languages_name.size(); ++i) { - HashMap<String,String> language = languages.get(i); - ApplContext translation = (ApplContext) translations.get(language.get("name")); - String property_translated = translation.getMsg().getString(property_name); - if (language.get("name").equals(default_lang)) { - vc.put(property_name, property_translated); - } else { - URI mail_translation = new URI("mailto", "w3c-translators@w3.org?Subject=["+property_name+"] CSS Validator Translation&body=Property:\n "+property_name+"\n\nText in English:\n "+ac_default.getMsg().getString(property_name)+"\n\nLanguage:\n "+language.get("name")+"\n\nTranslation:\n\n\n-- Help translate the CSS Validator:\nhttp://qa-dev.w3.org:8001/css-validator/translations.html", ""); - if (property_translated == null) { - translations_table.append("<td class=\"table_translation_missing\"><a title=\"submit a missing translation\" href=\"").append(StringEscapeUtils.escapeHtml(mail_translation.toASCIIString())).append("\">✘</a></td>\n"); - } else if ( property_translated.matches(".*translation unavailable.*")) { - translations_table.append("<td class=\"table_translation_missing\"><a title=\"submit a missing translation\" href=\"").append(StringEscapeUtils.escapeHtml(mail_translation.toASCIIString())).append("\">✘</a></td>\n"); - } else { - translations_table.append("<td class=\"table_translation_ok\"><span title=\"").append(StringEscapeUtils.escapeHtml(property_translated)).append("\">✔</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.append("<tbody>"); + int num_properties = 0; + while (properties_iterator.hasNext()) { + ++num_properties; + String property_name = String.valueOf(properties_iterator.next()); + translations_table.append("<tr><th scope=\"row\" class=\"property_name\">").append(property_name); + translations_table.append("<p>").append(StringEscapeUtils.escapeHtml(ac_default.getMsg().getString(property_name))); + translations_table.append("</p></th>"); + for (int i = 0; i < Messages.languages_name.size(); ++i) { + HashMap<String, String> language = languages.get(i); + ApplContext translation = (ApplContext) translations.get(language.get("name")); + String property_translated = translation.getMsg().getString(property_name); + if (language.get("name").equals(default_lang)) { + vc.put(property_name, property_translated); + } else { + URI mail_translation = new URI("mailto", "w3c-translators@w3.org?Subject=[" + property_name + "] CSS Validator Translation&body=Property:\n " + property_name + "\n\nText in English:\n " + ac_default.getMsg().getString(property_name) + "\n\nLanguage:\n " + language.get("name") + "\n\nTranslation:\n\n\n-- Help translate the CSS Validator:\nhttp://qa-dev.w3.org:8001/css-validator/translations.html", ""); + if (property_translated == null) { + translations_table.append("<td class=\"table_translation_missing\"><a title=\"submit a missing translation\" href=\"").append(StringEscapeUtils.escapeHtml(mail_translation.toASCIIString())).append("\">✘</a></td>\n"); + } else if (property_translated.matches(".*translation unavailable.*")) { + translations_table.append("<td class=\"table_translation_missing\"><a title=\"submit a missing translation\" href=\"").append(StringEscapeUtils.escapeHtml(mail_translation.toASCIIString())).append("\">✘</a></td>\n"); + } else { + translations_table.append("<td class=\"table_translation_ok\"><span title=\"").append(StringEscapeUtils.escapeHtml(property_translated)).append("\">✔</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.append("</tr>"); - if ( num_properties % 12 == 0) { + if (num_properties % 12 == 0) { translations_table.append("</tbody><tbody>").append(table_head); } } translations_table.append("</tbody></table>"); for (int i = 0; i < Messages.languages_name.size(); i++) { - name = String.valueOf(Messages.languages_name.get(i)); - HashMap<String,String> l = languages.get(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", Integer.toString(completeness_percent)); - // FIXME not needed // languages[i] = l; - } - 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.toString()); - vc.put("lang", "en"); - OutputStreamWriter aFileWriter = new OutputStreamWriter(new FileOutputStream(out_file), "UTF-8"); - tpl.merge(vc, aFileWriter); - aFileWriter.close(); - } catch (URISyntaxException e) { - e.printStackTrace(); - } catch (ResourceNotFoundException e) { - e.printStackTrace(); - } catch (ParseErrorException e) { - e.printStackTrace(); - } catch (MethodInvocationException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - done = true; - } + name = String.valueOf(Messages.languages_name.get(i)); + HashMap<String, String> l = languages.get(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", Integer.toString(completeness_percent)); + // FIXME not needed // languages[i] = l; + } + 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.toString()); + vc.put("lang", "en"); + OutputStreamWriter aFileWriter = new OutputStreamWriter(new FileOutputStream(out_file), "UTF-8"); + tpl.merge(vc, aFileWriter); + aFileWriter.close(); + } catch (URISyntaxException e) { + e.printStackTrace(); + } catch (ResourceNotFoundException e) { + e.printStackTrace(); + } catch (ParseErrorException e) { + e.printStackTrace(); + } catch (MethodInvocationException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + done = true; + } } } Index: translations.vm =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/index/translations.vm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- translations.vm 6 Mar 2008 22:49:46 -0000 1.6 +++ translations.vm 6 Sep 2011 14:40:30 -0000 1.7 @@ -17,13 +17,13 @@ <p>The table below lists all the text strings used to translate the CSS validator:</p> <ul class="translations_instructions"> -<li>Cells marked <span class='table_translation_missing'><a title="Cross Mark">✘</a></span> need a new or updated translation. Click on the relevant ✘ to submit a translation by mail.</li> -<li>Cells marked <span class='table_translation_ok'>✔</span> are translated and up-to-date. Hover above ✔ to read the current translation for each string.</li> +<li>Cells marked <span class="table_translation_missing"><a title="Cross Mark">✘</a></span> need a new or updated translation. Click on the relevant ✘ to submit a translation by mail.</li> +<li>Cells marked <span class="table_translation_ok">✔</span> are translated and up-to-date. Hover above ✔ to read the current translation for each string.</li> </ul> <p>You can help fill the blanks and complete the translation in <strong>your</strong> language!</p> <table id="translation_summary"> <thead><tr> -<th scope='col' class="property_name" id="properties">Property</th> +<th scope="col" class="property_name" id="properties">Property</th> #foreach ( $language in $languages ) #set ( $name = $language.get("name") ) #if ($name != "en") @@ -33,7 +33,8 @@ #set ( $real = $language.get("name") ) #end #set ($completeness = $language.get("completeness") ) - <th scope='col'>$real <br /> $completeness%</th> + #set ($engname = $language.get("engname") ) + <th scope="col" title="$engname">$real <br /> $completeness%</th> #end #end </tr></thead>
Received on Tuesday, 6 September 2011 14:40:40 UTC