String result = null;
String bundleBase = propertyToBundles.get(relatedProperty);
+ if (bundleBase == null) {
+ // this property has no translation
+ return null;
+ }
+
String filePath = bundleBase.replace('.', '/');
if (!"en".equals(locale.getLanguage())) {
filePath += "_" + locale.getLanguage();
return MessageFormat.format(message.replaceAll("'", "''"), parameters);
}
-
ClassLoader getBundleClassLoader() {
return i18nClassloader;
}
List<PluginMetadata> plugins = Arrays.asList(newPlugin("sqale"), newPlugin("frpack"), newPlugin("core"), newPlugin("checkstyle"), newPlugin("other"));
when(pluginRepository.getMetadata()).thenReturn(plugins);
- I18nClassloader i18nClassloader = new I18nClassloader(new ClassLoader[]{
+ I18nClassloader i18nClassloader = new I18nClassloader(new ClassLoader[] {
newCoreClassloader(), newFrenchPackClassloader(), newSqaleClassloader(), newCheckstyleClassloader()
});
manager = new I18nManager(pluginRepository);
assertThat(manager.message(Locale.CHINA, "sqale.page", null)).isEqualTo("Sqale page title");
}
-
@Test
public void should_return_default_value_if_missing_key() {
assertThat(manager.message(Locale.ENGLISH, "unknown", "default")).isEqualTo("default");
assertThat(html).isNull();
}
+ @Test
+ public void should_return_null_if_rule_not_internationalized() {
+ String html = manager.messageFromFile(Locale.ENGLISH, "UnknownRule.html", "foo.rule1.name", false);
+ assertThat(html).isNull();
+ }
+
@Test
public void should_locate_french_file() {
String html = manager.messageFromFile(Locale.FRENCH, "ArchitectureRule.html", "checkstyle.rule1.name", false);