01: /**
02: *******************************************************************************
03: * Copyright (C) 2002-2004, International Business Machines Corporation and *
04: * others. All Rights Reserved. *
05: *******************************************************************************
06: */package com.ibm.icu.dev.tool.localeconverter;
07:
08: import java.io.*;
09: import java.util.*;
10:
11: /**
12:
13: The ConvertJavaLocale application converts java locales to
14: Java and ICU Locale files. It's usage is as follows
15:
16: ConvertJavaLocale [-11] [-12] [-icu] locale...
17:
18: Usage
19:
20: -11
21: If this option is specified, data is output in
22: Java 1.1.x locale format.
23:
24: -12
25: If this option is specified, data is output in
26: Java 1.2.x locale format. If an output format
27: is not specified, -12 is the default.
28:
29: -icu
30: If this option is specified, data is output in
31: ICU locale format.
32:
33: locale
34: The locale to convert
35:
36:
37: */
38: /*
39: *******************************************************************************
40: * Copyright (C) 2002-2003, International Business Machines Corporation and *
41: * others. All Rights Reserved. *
42: *******************************************************************************
43: */
44: public class ConvertAllJavaLocales {
45: public static void main(String args[]) {
46: try {
47: new ConvertAllJavaLocales(args);
48: } catch (Throwable t) {
49: System.err.println("Unknown error: " + t);
50: }
51: }
52:
53: public ConvertAllJavaLocales(String argsIn[]) {
54: try {
55: String packageName = argsIn[0];
56: System.out.println("This is the packagename : "
57: + packageName);
58: String classname = packageName + ".Locale";
59: //classname.concat();
60: System.out.println("This is the classname : " + classname);
61: /* Class cl = Class.forName(classname);
62: Class[] paramList=null;
63: Method gvl = cl.getMethod("getAvailableLocales", paramList);
64: Object[] params = new Object[]{""};
65: gvl.invoke(null,params);*/
66: final Locale[] locales = java.util.Locale
67: .getAvailableLocales();//(Locale[])gvl.invoke(null,params);;
68:
69: for (int i = 0; i < locales.length; i++) {
70: final String localeName = locales[i].toString();
71: final String[] args = { "-package", packageName,
72: "-icu", localeName };
73:
74: System.out.println("Converting " + localeName);
75:
76: final FileOutputStream outFile = new FileOutputStream(
77: localeName + ".txt");
78: final PrintStream out = new PrintStream(outFile, true);
79:
80: new ConvertJavaLocale(args, out);
81:
82: out.close();
83: }
84: System.out.println("Converting root locale");
85: final String[] args = { "-package", packageName, "-icu",
86: "root" };
87: final FileOutputStream outFile = new FileOutputStream(
88: "root.txt");
89: final PrintStream out = new PrintStream(outFile, true);
90: new ConvertJavaLocale(args, out);
91: out.close();
92:
93: } catch (IOException e) {
94: System.err.println("Unexpected IO error");
95: } catch (Exception e) {
96: e.printStackTrace();
97: }
98: }
99: }
|