void doStart(ClassLoader classloader) {
this.classloader = classloader;
propertyToBundles = Maps.newHashMap();
- for (PluginMetadata plugin : pluginRepository.getMetadata()) {
- try {
- String bundleKey = BUNDLE_PACKAGE + plugin.getKey();
- ResourceBundle bundle = ResourceBundle.getBundle(bundleKey, Locale.ENGLISH, this.classloader, control);
- Enumeration<String> keys = bundle.getKeys();
- while (keys.hasMoreElements()) {
- String key = keys.nextElement();
- propertyToBundles.put(key, bundleKey);
- }
- } catch (MissingResourceException e) {
- // ignore
+ Collection<PluginMetadata> metadata = pluginRepository.getMetadata();
+ if (metadata.isEmpty()) {
+ addPlugin("core");
+ } else {
+ for (PluginMetadata plugin : pluginRepository.getMetadata()) {
+ addPlugin(plugin.getKey());
}
}
LOG.debug(String.format("Loaded %d properties from l10n bundles", propertyToBundles.size()));
}
+ private void addPlugin(String pluginKey){
+ try {
+ String bundleKey = BUNDLE_PACKAGE + pluginKey;
+ ResourceBundle bundle = ResourceBundle.getBundle(bundleKey, Locale.ENGLISH, this.classloader, control);
+ Enumeration<String> keys = bundle.getKeys();
+ while (keys.hasMoreElements()) {
+ String key = keys.nextElement();
+ propertyToBundles.put(key, bundleKey);
+ }
+ } catch (MissingResourceException e) {
+ // ignore
+ }
+ }
@Override
public void stop() {
manager.doStart(getClass().getClassLoader());
}
+ @Test
+ public void load_core_bundle_when_no_plugin() {
+ DefaultI18n manager = new DefaultI18n(mock(PluginRepository.class), system2);
+ manager.doStart(getClass().getClassLoader());
+
+ assertThat(manager.getPropertyKeys().contains("any")).isTrue();
+ assertThat(manager.getPropertyKeys().contains("assignee")).isTrue();
+ }
+
@Test
public void introspect_all_available_properties() {
assertThat(manager.getPropertyKeys().contains("any")).isTrue();