Skip to content

Commit

Permalink
fix(i18n): subscription translations not loaded
Browse files Browse the repository at this point in the history
* fix PathPatternMatching to load resources from all jars
* adapt tests that were already showing the issue (only resources from src/test/resources/i18n were loaded. src/main/resources/i18n was ignored)

Covers [RUNTIME-1769](https://bonitasoft.atlassian.net/browse/RUNTIME-1769)

Report of   bonitasoft/bonita-web-sp@6f8f9ed
  • Loading branch information
abirembaut committed Oct 19, 2023
1 parent d974c4d commit 9fa7bbc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private TreeMap<String, String> loadLocale(final LOCALE locale, List<File> files
public List<InputStream> getStreams(LOCALE locale) {
ResourcePatternResolver patternResolver = new PathMatchingResourcePatternResolver();
try {
Resource[] resources = patternResolver.getResources("classpath:/i18n/" + getLocaleRegexForResource(locale));
Resource[] resources = patternResolver.getResources("classpath*:i18n/" + getLocaleRegexForResource(locale));
List<InputStream> streams = new ArrayList<>(resources.length);
for (Resource resource : resources) {
InputStream stream = resource.getInputStream();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ public class I18nTest {
@Test
public void getStreams_should_read_from_classpath() {
final List<InputStream> streams = I18n.getInstance().getStreams(AbstractI18n.LOCALE.fr);
assertThat(streams).hasSize(3);
//retrieving resources from both src/test/resources and src/main/resources
assertThat(streams).hasSize(6);
assertThat(streams.get(0)).isNotNull();
}

@Test
public void getStreams_should_not_fail_if_no_resource_found() {
final List<InputStream> streams = I18n.getInstance().getStreams(AbstractI18n.LOCALE.es);
final List<InputStream> streams = I18n.getInstance().getStreams(AbstractI18n.LOCALE.de);
assertThat(streams).isEmpty();
}

Expand Down

0 comments on commit 9fa7bbc

Please sign in to comment.