Skip to content

Commit

Permalink
🐛 (i18n) 修复国际化 resource bundle 无法正确加载的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Hccake committed May 7, 2024
1 parent 1e345aa commit 0900399
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected List<String> calculateFilenamesForLocale(String basename, Locale local
private Resource[] getResources(String resourceLocationPattern) throws IOException {
// 支持用 . 表示文件层级
resourceLocationPattern = resourceLocationPattern.replace(".", "/");
return this.resolver.getResources(resourceLocationPattern + PROPERTIES_SUFFIX);
return this.resolver.getResources("classpath*:" + resourceLocationPattern + PROPERTIES_SUFFIX);
}

private boolean containsWildcard(String str) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class HierarchicalMessageSourceTest {
MessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource = new WildcardReloadableResourceBundleMessageSource();
// Specify the location of the properties file
messageSource.setBasename("classpath:test-*");
messageSource.setBasename("test-*");
messageSource.setDefaultEncoding("UTF-8");
messageSource.setFallbackToSystemLocale(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ReloadableResourceBundleMessageSource messageSource(boolean fallbackToSystemLoca
ReloadableResourceBundleMessageSource messageSource = new WildcardReloadableResourceBundleMessageSource();

// Specify the location of the properties file
messageSource.setBasename("classpath*:org.ballcat.**.messages");
messageSource.setBasename("org.ballcat.**.messages");
messageSource.setDefaultEncoding("UTF-8");
messageSource.setFallbackToSystemLocale(fallbackToSystemLocale);
return messageSource;
Expand Down

0 comments on commit 0900399

Please sign in to comment.