messages.emitClass(logger, generatedLocale);
}
context.commit(logger, pw);
}
// Generate a translatable output file if requested.
Generate generate = getClassAnnotation(targetClass, Generate.class);
if (generate != null) {
String path = generate.fileName();
if (Generate.DEFAULT.equals(path)) {
path = targetClass.getPackage().getName() + "."
+ targetClass.getName().replace('.', '_');
} else if (path.endsWith(File.pathSeparator)) {
path = path + targetClass.getName().replace('.', '_');
}
String[] genLocales = generate.locales();
boolean found = false;
if (genLocales.length != 0) {
// verify the current locale is in the list
for (String genLocale : genLocales) {
if (GwtLocale.DEFAULT_LOCALE.equals(genLocale)) {
// Locale "default" gets special handling because of property
// fallbacks; "default" might be mapped to any real locale.
try {
SelectionProperty localeProp = context.getPropertyOracle()
.getSelectionProperty(logger, "locale");
String defaultLocale = localeProp.getFallbackValue();
if (defaultLocale.length() > 0) {
genLocale = defaultLocale;
}
} catch (BadPropertyValueException e) {
throw error(logger, "Could not get 'locale' property");
}
}
if (genLocale.equals(locale.toString())) {
found = true;
break;
}
}
} else {
// Since they want all locales, this is guaranteed to be one of them.
found = true;
}
if (found) {
for (String genClassName : generate.format()) {
MessageCatalogFormat msgWriter = null;
MessageCatalogFactory msgCatFactory = null;
try {
// TODO(jat): if GWT is ever modified to take a classpath for user
// code as an option, we would need to use the user classloader here