Skip to content
Snippets Groups Projects
Commit 49b954a7 authored by Thomas Mortagne's avatar Thomas Mortagne
Browse files

XWIKI-15140: Allow giving a chain of translations keys fallbacks to the localization script service

parent 99a869dc
No related branches found
No related tags found
No related merge requests found
......@@ -364,10 +364,12 @@ public String render(Collection<String> keys, Syntax syntax, Collection<?> param
Translation translation = null;
for (String key : keys) {
translation = this.localization.getTranslation(key, locale);
if (key != null) {
translation = this.localization.getTranslation(key, locale);
if (translation != null) {
break;
if (translation != null) {
break;
}
}
}
......
......@@ -113,7 +113,7 @@ public void render() throws Exception
{
assertEquals("print result", localizationScriptService.render("key"));
assertEquals("print result",
localizationScriptService.render(Arrays.asList("not existing key", "key", "another key")));
localizationScriptService.render(Arrays.asList(null, "not existing key", "key", "another key")));
}
@Test
......@@ -121,7 +121,7 @@ public void renderWithSyntax() throws Exception
{
assertEquals("print result", localizationScriptService.render("key", Syntax.PLAIN_1_0));
assertEquals("print result", localizationScriptService
.render(Arrays.asList("not existing key", "key", "another key"), Syntax.PLAIN_1_0));
.render(Arrays.asList(null, "not existing key", "key", "another key"), Syntax.PLAIN_1_0));
}
@Test
......@@ -129,15 +129,15 @@ public void renderWithSyntaxAndParameters() throws Exception
{
assertEquals("print result", localizationScriptService.render("key", Syntax.PLAIN_1_0, Arrays.asList()));
assertEquals("print result", localizationScriptService
.render(Arrays.asList("not existing key", "key", "another key"), Syntax.PLAIN_1_0, Arrays.asList()));
.render(Arrays.asList(null, "not existing key", "key", "another key"), Syntax.PLAIN_1_0, Arrays.asList()));
}
@Test
public void renderWithParameters() throws Exception
{
assertEquals("print result", localizationScriptService.render("key", Arrays.asList()));
assertEquals("print result",
localizationScriptService.render(Arrays.asList("not existing key", "key", "another key"), Arrays.asList()));
assertEquals("print result", localizationScriptService
.render(Arrays.asList(null, "not existing key", "key", "another key"), Arrays.asList()));
}
@Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment