mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-16 10:17:23 +00:00
ICU-2055 updates, CVS versions, comparator update
X-SVN-Rev: 16599
This commit is contained in:
parent
83f812dd0a
commit
9a5e3c2969
4 changed files with 140 additions and 65 deletions
|
@ -687,9 +687,7 @@ import com.ibm.icu.util.UResourceBundle;
|
|||
}
|
||||
}
|
||||
out.println("</table>");
|
||||
out.println("</body>");
|
||||
out.println("</html>");
|
||||
out.close();
|
||||
writeFooterAndClose(out);
|
||||
}
|
||||
|
||||
Object[][] fixList = {
|
||||
|
@ -829,10 +827,11 @@ import com.ibm.icu.util.UResourceBundle;
|
|||
Set s = new TreeSet((Collection)elementToAttribute.get(attribute));
|
||||
s.removeAll(result);
|
||||
if (s.size() != 0) {
|
||||
System.out.println("Warning: Missing values for " + element + ", " + attribute);
|
||||
System.out.print("Warning: Missing values for " + element + ", " + attribute + ": ");
|
||||
for (Iterator it = s.iterator(); it.hasNext(); ) {
|
||||
System.out.println(it.next());
|
||||
System.out.print(it.next() + " ");
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1430,8 +1429,8 @@ import com.ibm.icu.util.UResourceBundle;
|
|||
String chainName = getChainName(stack);
|
||||
if (!chainName.equals(lastChainName)) {
|
||||
if (out != null) {
|
||||
out.println("</table></body></html>");
|
||||
out.close();
|
||||
out.println("</table>");
|
||||
writeFooterAndClose(out);
|
||||
}
|
||||
allTypes.add(chainName); // add to the list
|
||||
out = openAndDoHeader(chainName);
|
||||
|
@ -1481,7 +1480,8 @@ import com.ibm.icu.util.UResourceBundle;
|
|||
if(out==null) {
|
||||
System.err.println("Out = null?");
|
||||
} else {
|
||||
out.println("</table></body></html>");
|
||||
out.println("</table>");
|
||||
writeFooterAndClose(out);
|
||||
out.close();
|
||||
}
|
||||
writeIndex();
|
||||
|
@ -1503,7 +1503,7 @@ import com.ibm.icu.util.UResourceBundle;
|
|||
out.println("<link rel='stylesheet' type='text/css' href='by_type.css'>");
|
||||
out.println("</head>");
|
||||
out.println("<body>");
|
||||
out.println("<ul><li><a href=\"index.html\">index</a></li></ul>");
|
||||
out.println("<ul><li><a href=\"index.html\">Index</a></li></ul>");
|
||||
out.println("<table>");
|
||||
return out;
|
||||
}
|
||||
|
@ -1531,8 +1531,9 @@ import com.ibm.icu.util.UResourceBundle;
|
|||
String f = (String)e.next();
|
||||
out.println(" <li><a href=\"" + f + ".html" + "\">" + f + "</a>");
|
||||
}
|
||||
out.println("</ul></body></html>");
|
||||
out.close();
|
||||
out.println("</ul>");
|
||||
out.println("<a href='http://www.jtcsv.com/cgibin/cldrwiki.pl?ByType'>About this chart</a> <br/>");
|
||||
writeFooterAndClose(out);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1724,5 +1725,11 @@ import com.ibm.icu.util.UResourceBundle;
|
|||
}
|
||||
return result;
|
||||
}
|
||||
private static void writeFooterAndClose(PrintWriter out)
|
||||
{
|
||||
out.println("Generated " + java.util.Calendar.getInstance().getTime());
|
||||
out.println("</body></html>");
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
|
@ -636,14 +636,18 @@ public class LDML2ICUConverter {
|
|||
if(ldml == null) {
|
||||
throw new RuntimeException("ERROR: no <ldml> node found in parseBundle()");
|
||||
}
|
||||
|
||||
if(verbose) {
|
||||
System.out.print("INFO: ");
|
||||
}
|
||||
for(Node node=ldml.getFirstChild(); node!=null; node=node.getNextSibling()){
|
||||
if(node.getNodeType()!=Node.ELEMENT_NODE){
|
||||
continue;
|
||||
}
|
||||
String name = node.getNodeName();
|
||||
ICUResourceWriter.Resource res = null;
|
||||
|
||||
if(verbose) {
|
||||
System.out.print(name+" ");
|
||||
}
|
||||
if(name.equals(LDMLConstants.ALIAS)){
|
||||
ICUResourceWriter.ResourceString str = new ICUResourceWriter.ResourceString();
|
||||
str.name = "\"%%ALIAS\"";
|
||||
|
@ -705,6 +709,9 @@ public class LDML2ICUConverter {
|
|||
}
|
||||
xpath.delete(savedLength,xpath.length());
|
||||
}
|
||||
if(verbose) {
|
||||
System.out.println();
|
||||
}
|
||||
// now fetch the specials and append to the real bundle
|
||||
if(specialsDir!=null && ULocale.getCountry(locName).equals("")){
|
||||
if(specialsDoc == null) {
|
||||
|
@ -3469,7 +3476,13 @@ public class LDML2ICUConverter {
|
|||
buffer.append("// * Corporation and others. All Rights Reserved."+LINESEP);
|
||||
buffer.append("// * Tool: com.ibm.icu.dev.tool.cldr.LDML2ICUConverter.java" + LINESEP);
|
||||
// buffer.append("// * Date & Time: " + c.get(Calendar.YEAR) + "/" + (c.get(Calendar.MONTH)+1) + "/" + c.get(Calendar.DAY_OF_MONTH) + " " + c.get(Calendar.HOUR_OF_DAY) + COLON + c.get(Calendar.MINUTE)+ LINESEP);
|
||||
buffer.append("// * Source File: " + fileName + LINESEP);
|
||||
// String ver = LDMLUtilities.getCVSVersion(fileName);
|
||||
// if(ver==null) {
|
||||
// ver = "";
|
||||
// } else {
|
||||
// ver = " v" + ver;
|
||||
// }
|
||||
buffer.append("// * Source File: " + fileName + LINESEP);
|
||||
buffer.append("// *" + LINESEP);
|
||||
buffer.append("// ***************************************************************************" + LINESEP);
|
||||
writeLine(writer, buffer.toString());
|
||||
|
|
|
@ -271,7 +271,7 @@ public class LDMLComparator {
|
|||
//System.out.println("INFO: no file created (nothing to write..) " + fileName);
|
||||
} else {
|
||||
ourCvsVersion = "";
|
||||
getCvsVersion();
|
||||
getCVSVersion();
|
||||
OutputStreamWriter os = new OutputStreamWriter(new FileOutputStream(fileName),encoding);
|
||||
System.out.println("INFO: Writing: " + fileName + "\t(" + m_totalCount + " items)");
|
||||
PrintWriter writer = new PrintWriter(os);
|
||||
|
@ -288,7 +288,7 @@ public class LDMLComparator {
|
|||
indexwriter.println(" <td><a href=\"" + localeStr+".html" + "\">" +
|
||||
ourLocale.getDisplayName() + "</a></td>");
|
||||
indexwriter.println(" <td>" + m_totalCount + "</td>");
|
||||
indexwriter.println(" <td>" + getCvsLink(localeStr,ourCvsVersion) + ourCvsVersion + "</a></td>");
|
||||
indexwriter.println(" <td>" + LDMLUtilities.getCVSLink(localeStr,ourCvsVersion) + ourCvsVersion + "</a></td>");
|
||||
indexwriter.println("</tr>");
|
||||
is.close();
|
||||
}
|
||||
|
@ -720,7 +720,7 @@ public class LDMLComparator {
|
|||
"<input type=submit value=\"" + "Test" + "\"/>" +
|
||||
"</form>");
|
||||
}
|
||||
if(m_Vetting && element.referenceUrl != null) {
|
||||
if(/*m_Vetting &&*/ element.referenceUrl != null) {
|
||||
writer.print("<br><div align='right'><a href=\"" + element.referenceUrl + "\"><i>(Ref)</i></a></div>");
|
||||
}
|
||||
writer.print("</td>");
|
||||
|
@ -808,8 +808,8 @@ public class LDMLComparator {
|
|||
"<a href=\"./index.html\">Main and About</a>, "+
|
||||
"</b></p>\n");
|
||||
if((ourCvsVersion!=null) && (ourCvsVersion.length()>0)) {
|
||||
writer.println("<h3><tt>"+ getCvsLink(localeStr) + localeStr + ".xml</a> version " +
|
||||
getCvsLink(localeStr,ourCvsVersion) + ourCvsVersion + "</a></tt></h3>");
|
||||
writer.println("<h3><tt>"+ LDMLUtilities.getCVSLink(localeStr) + localeStr + ".xml</a> version " +
|
||||
LDMLUtilities.getCVSLink(localeStr,ourCvsVersion) + ourCvsVersion + "</a></tt></h3>");
|
||||
}
|
||||
writer.print( " <table>\n");
|
||||
}
|
||||
|
@ -1789,48 +1789,9 @@ public class LDMLComparator {
|
|||
writer.print(" </table>\n");
|
||||
}
|
||||
|
||||
private void getCvsVersion()
|
||||
private void getCVSVersion()
|
||||
{
|
||||
// private String localeStr;
|
||||
// private String ourCvsVersion = null;
|
||||
// sourceFolder
|
||||
// localeStr = goldFileName.substring(goldFileName.lastIndexOf(File.separatorChar)+1,goldFileName.lastIndexOf('.'));
|
||||
int index = goldFileName.lastIndexOf(File.separatorChar);
|
||||
String sourceDir = goldFileName.substring(0, index);
|
||||
ourCvsVersion = LDMLUtilities.getCVSVersion(goldFileName);
|
||||
}
|
||||
|
||||
File entriesFile = new File(sourceDir + File.separatorChar + "CVS","Entries");
|
||||
if(!entriesFile.exists() || !entriesFile.canRead()) {
|
||||
System.out.println("Can't read, won't try to get CVS " + entriesFile.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
BufferedReader r = new BufferedReader(new FileReader(entriesFile.getPath()));
|
||||
String s;
|
||||
while((s=r.readLine())!=null) {
|
||||
String lookFor = "/"+localeStr+".xml/";
|
||||
if(s.startsWith(lookFor)) {
|
||||
String ver = s.substring(lookFor.length());
|
||||
ver = ver.substring(0,ver.indexOf('/'));
|
||||
ourCvsVersion = ver;
|
||||
}
|
||||
}
|
||||
r.close();
|
||||
} catch ( Throwable th ) {
|
||||
System.err.println(th.toString() + " trying to read CVS Entries file " + entriesFile.getPath());
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static final String getCvsLink(String locale)
|
||||
{
|
||||
return "<a href=\"http://oss.software.ibm.com/cvs/icu/locale/common/main/" + locale + ".xml\">";
|
||||
}
|
||||
|
||||
private static final String getCvsLink(String locale, String version)
|
||||
{
|
||||
return "<a href=\"http://oss.software.ibm.com/cvs/icu/locale/common/main/" + locale + ".xml?rev=" +
|
||||
version + "&content-type=text/x-cvsweb-markup\">";
|
||||
}
|
||||
} //end of class definition/declaration
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.io.PrintWriter;
|
|||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.*;
|
||||
|
||||
// DOM imports
|
||||
import org.apache.xpath.XPathAPI;
|
||||
|
@ -55,7 +56,7 @@ import org.xml.sax.SAXParseException;
|
|||
* Window - Preferences - Java - Code Generation - Code and Comments
|
||||
*/
|
||||
public class LDMLUtilities {
|
||||
|
||||
|
||||
/**
|
||||
* Creates a fully resolved locale starting with root and
|
||||
* @param sourceDir
|
||||
|
@ -94,14 +95,18 @@ public class LDMLUtilities {
|
|||
String[] constituents = locale.split("_");
|
||||
String loc=null;
|
||||
boolean isAvailable = false;
|
||||
//String lastLoc = "root";
|
||||
for(int i=0; i<constituents.length; i++){
|
||||
if(loc==null){
|
||||
loc = constituents[i];
|
||||
if(loc==null){
|
||||
loc = constituents[i];
|
||||
}else{
|
||||
loc = loc +"_"+ constituents[i];
|
||||
}
|
||||
Document doc = null;
|
||||
|
||||
// Try cache
|
||||
//doc = readMergeCache(sourceDir, lastLoc, loc);
|
||||
//if(doc == null) { ..
|
||||
String fileName = sourceDir+File.separator+loc+".xml";
|
||||
File file = new File(fileName);
|
||||
if(file.exists()){
|
||||
|
@ -132,6 +137,9 @@ public class LDMLUtilities {
|
|||
System.out.println("The chars are: "+ getNodeValue(ec));
|
||||
}
|
||||
*/
|
||||
|
||||
//writeMergeCache(sourceDir, lastLoc, loc, full);
|
||||
//lastLoc = loc;
|
||||
}else{
|
||||
if(!ignoreUnavailable){
|
||||
throw new RuntimeException("Could not find: " +fileName);
|
||||
|
@ -146,7 +154,7 @@ public class LDMLUtilities {
|
|||
|
||||
return full;
|
||||
}
|
||||
|
||||
|
||||
public static Document revalidate(Document doc, String fileName){
|
||||
// what a waste!!
|
||||
// to revalidate an in-memory DOM tree we need to first
|
||||
|
@ -1289,4 +1297,90 @@ System.err.println(filename2 + ":" + e.getLineNumber() + (col>=0?":" + col:"")
|
|||
}
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
// Utility functions, HTML and such.
|
||||
|
||||
public static final String getCVSLink(String locale)
|
||||
{
|
||||
return "<a href=\"http://oss.software.ibm.com/cvs/icu/locale/common/main/" + locale + ".xml\">";
|
||||
}
|
||||
|
||||
public static final String getCVSLink(String locale, String version)
|
||||
{
|
||||
return "<a href=\"http://oss.software.ibm.com/cvs/icu/locale/common/main/" + locale + ".xml?rev=" +
|
||||
version + "&content-type=text/x-cvsweb-markup\">";
|
||||
}
|
||||
static public String getCVSVersion(String fileName)
|
||||
{
|
||||
int index = fileName.lastIndexOf(File.separatorChar);
|
||||
if(index==-1) {
|
||||
return null;
|
||||
}
|
||||
String sourceDir = fileName.substring(0, index);
|
||||
return getCVSVersion(sourceDir, new File(fileName).getName());
|
||||
}
|
||||
static public String getCVSVersion(String sourceDir, String fileName) {
|
||||
String aVersion = null;
|
||||
File entriesFile = new File(sourceDir + File.separatorChar + "CVS","Entries");
|
||||
if(!entriesFile.exists() || !entriesFile.canRead()) {
|
||||
System.out.println("Can't read, won't try to get CVS " + entriesFile.toString());
|
||||
return null;
|
||||
}
|
||||
try{
|
||||
BufferedReader r = new BufferedReader(new FileReader(entriesFile.getPath()));
|
||||
String s;
|
||||
while((s=r.readLine())!=null) {
|
||||
String lookFor = "/"+fileName+"/";
|
||||
if(s.startsWith(lookFor)) {
|
||||
String ver = s.substring(lookFor.length());
|
||||
ver = ver.substring(0,ver.indexOf('/'));
|
||||
aVersion = ver;
|
||||
}
|
||||
}
|
||||
r.close();
|
||||
} catch ( Throwable th ) {
|
||||
System.err.println(th.toString() + " trying to read CVS Entries file " + entriesFile.getPath());
|
||||
return null;
|
||||
}
|
||||
return aVersion;
|
||||
}
|
||||
|
||||
// // Caching Resolution
|
||||
// private static File getCacheName(String sourceDir, String last, String loc)
|
||||
// {
|
||||
// //File xCacheDir = new File((CachingEntityResolver.getCacheDir()!=null)?CachingEntityResolver.getCacheDir():"/tmp/cldrres");
|
||||
// return new File(sourceDir).getName() + "_" + last + "." + loc;
|
||||
// }
|
||||
|
||||
// Document readMergeCache(String sourceDir, String last, String loc)
|
||||
// {
|
||||
// File cacheName = getCacheName(String sourceDir, last, loc);
|
||||
// System.out.println(" M: " + cacheName);
|
||||
// File cacheFile = new File(xCacheDir, cacheName + ".xml");
|
||||
// if(cacheFile.exists()) { // && is newer than last, loc
|
||||
// doc = parse(cacheFile.getPath(),ignoreUnavailable);
|
||||
// }
|
||||
// if(doc!=null) {
|
||||
// System.out.println("Cache hit for " + cacheName);
|
||||
// }
|
||||
// return doc;
|
||||
// }
|
||||
|
||||
// void writeMergeCache(String sourceDir, String last, String loc, Document full)
|
||||
// {
|
||||
// try {
|
||||
// OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(cacheFile),"UTF-8");
|
||||
// PrintWriter pw = new PrintWriter(writer);
|
||||
// printDOMTree(full,pw);
|
||||
// long stop = System.currentTimeMillis();
|
||||
// long total = (stop-start);
|
||||
// double s = total/1000.;
|
||||
// System.out.println(" " + cacheName + " parse time: " + s + "s");
|
||||
// pw.println("<!-- " + cacheName + " parse time: " + s + "s -->");
|
||||
// writer.close();
|
||||
// } catch (Throwable t) {
|
||||
// System.err.println(t.toString() + " while trying to write cache file " + cacheName);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue