throws IOException {
InputStream is = GWTDictionaryBuilder.class.getClassLoader().getResourceAsStream(bundleName.replace('.', '/') + ".properties");
if (is == null) {
throw new FileNotFoundException("ERROR : Couldn't find bundle with name " + bundleName.replace('.', '/') + ".properties in class loader, skipping...");
}
ResourceBundle defBundle = new PropertyResourceBundle(is);
is.close();
ResourceBundle bundle = null;
if (locale != null) {
try {
bundle = ResourceBundle.getBundle(bundleName, locale);
} catch (MissingResourceException e) {
bundle = defBundle;
}
} else {
bundle = defBundle;
}
File target = new File(targetFolder, targetFileName + (locale != null ? "_" + locale.toString() : "") + ".js");
System.out.print("Creating " + target + " ...");
PrintWriter out = new PrintWriter(target);
Enumeration<String> keyEnum = defBundle.getKeys();
List<String> keys = new LinkedList<String>();
while (keyEnum.hasMoreElements()) {
keys.add(keyEnum.nextElement());
}
Collections.sort(keys);
out.print("var " + Messages.DICTIONARY_NAME + "={");
if (!minified) {
out.println();
}
for (Iterator<String> iterator = keys.iterator(); iterator.hasNext();) {
String key = iterator.next();
String value = null;
try {
value = bundle.getString(key);
} catch (MissingResourceException e) {
try {
value = defBundle.getString(key);
} catch (MissingResourceException e2) {
value = null;
}
}
if (value != null) {