blob: 88fec5cc1f50bd81d5267f5558147852506e5981 [file] [log] [blame]
package com.ibm.icu.dev.tool.localeconverter;
import java.io.*;
import java.util.*;
/**
The ConvertJavaLocale application converts java locales to
Java and ICU Locale files. It's usage is as follows
ConvertJavaLocale [-11] [-12] [-icu] locale...
Usage
-11
If this option is specified, data is output in
Java 1.1.x locale format.
-12
If this option is specified, data is output in
Java 1.2.x locale format. If an output format
is not specified, -12 is the default.
-icu
If this option is specified, data is output in
ICU locale format.
locale
The locale to convert
*/
import java.lang.reflect.*;
/*
*******************************************************************************
* Copyright (C) 2002-2004, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/tool/localeconverter/ConvertAllJavaLocales.java,v $
* $Date: 2002/02/16 03:05:27 $
* $Revision: 1.2 $
*
*****************************************************************************************
*/
public class ConvertAllJavaLocales {
public static void main(String args[]) {
try {
new ConvertAllJavaLocales(args);
} catch (Throwable t) {
System.err.println("Unknown error: "+t);
}
}
public ConvertAllJavaLocales(String argsIn[]) {
try {
String packageName = argsIn[0];
System.out.println("This is the packagename : "+packageName);
String classname = packageName+".Locale";
//classname.concat();
System.out.println("This is the classname : "+classname);
/* Class cl = Class.forName(classname);
Class[] paramList=null;
Method gvl = cl.getMethod("getAvailableLocales", paramList);
Object[] params = new Object[]{""};
gvl.invoke(null,params);*/
final Locale[] locales = java.util.Locale.getAvailableLocales();//(Locale[])gvl.invoke(null,params);;
for (int i = 0; i < locales.length; i++) {
final String localeName = locales[i].toString();
final String[] args = {"-package",packageName,"-icu", localeName};
System.out.println("Converting "+localeName);
final FileOutputStream outFile = new FileOutputStream("ICULocale_"+localeName);
final PrintStream out = new PrintStream(outFile, true);
new ConvertJavaLocale(args, out);
out.close();
}
} catch (IOException e) {
System.err.println("Unexpected IO error");
}catch (Exception e) {
e.printStackTrace();
}
}
}