changeset 728:1931cf09c5bc

Eclipse looks in wrong bundle for externalized strings In Eclipse, when controllers that reside in client-core look up strings via the Translate class in common-core we get the following MissingResourceException: Caused by: java.util.MissingResourceException: Can't find bundle for base name com.redhat.thermostat.client.locale.strings, locale en_US at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1499) at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1322) at java.util.ResourceBundle.getBundle(ResourceBundle.java:724) at com.redhat.thermostat.common.locale.Translate.<init>(Translate.java:47) at com.redhat.thermostat.client.locale.LocaleResources.createLocalizer(LocaleResources.java:208) at com.redhat.thermostat.client.ui.HostCpuController.<clinit>(HostCpuController.java:64) ... 91 more This appears to be caused by Eclipse's BundleLoader only looking within Translate's bundle (common-core) for string.properties, even though the package name contains client.core. The result is a file lookup on _common_/core/src/com/redhat/thermostat/_client_/core... which will never exist. A workaround is to specify the classloader of the LocaleResources class passed to Translate, instead of using the default classloader. Reviewed-by: vanaltj Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-October/003864.html
author Elliott Baron <ebaron@redhat.com>
date Tue, 23 Oct 2012 16:54:51 -0400
parents bfbc04020529
children e80304692688
files common/core/src/main/java/com/redhat/thermostat/common/locale/Translate.java
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/common/core/src/main/java/com/redhat/thermostat/common/locale/Translate.java	Tue Oct 23 14:53:20 2012 -0400
+++ b/common/core/src/main/java/com/redhat/thermostat/common/locale/Translate.java	Tue Oct 23 16:54:51 2012 -0400
@@ -37,6 +37,7 @@
 package com.redhat.thermostat.common.locale;
 
 import java.text.MessageFormat;
+import java.util.Locale;
 import java.util.ResourceBundle;
 
 public class Translate<T extends Enum<T>> {
@@ -44,7 +45,7 @@
     private final ResourceBundle resourceBundle;
 
     public Translate(String stringResources, Class<T> enumClass) {
-        this(ResourceBundle.getBundle(stringResources), enumClass);
+        this(ResourceBundle.getBundle(stringResources, Locale.getDefault(), enumClass.getClassLoader()), enumClass);
     }
 
     Translate(ResourceBundle resourceBundle, Class<T> enumClass) {