grails-core icon indicating copy to clipboard operation
grails-core copied to clipboard

resourcebundle basenames order not respected

Open robertoschwald opened this issue 4 years ago • 2 comments

Steps to Reproduce

Define the PluginAwareResourceBundleMessageSource in resources.groovy and set the basenames array.

Expected Behaviour

Grails respects the order of basenames defined, so one is able to overwrite existing keys with new ones in a separate bundle. This is especially useful if you migrate a project with thousands of translations in many languages and need to re-define key texts. For this, you use a basename which is defined first in the list. Of course you can play around with bundle naming, as this is the default behaviour of the PluginAwareResourceBundleMessageSource, but the AbstractMessageSource.setBasenames() doc says: "The associated resource bundles will be checked sequentially when resolving a message code". Also, Spring ReloadableResourceBundle uses a similar functionality.

Actual Behaviour

Grails ignores the basenames order, so you cannot overwrite bundle keys in bundles you defined to be resolved first.

Environment Information

  • Operating System: Doesn't matter. macOS 11 in this case
  • Grails Version: Grails 3 and 4 affected
  • JDK Version: 8 or 11
  • Container Version (If Applicable): Doesn't matter.

Example Application

https://github.com/robertoschwald/GrailsPluginAwareBasenamesOrderBug

robertoschwald avatar May 02 '21 10:05 robertoschwald

PR follows.

robertoschwald avatar May 02 '21 10:05 robertoschwald

https://github.com/apache/grails-core/pull/14753

jamesfredley avatar Aug 18 '25 22:08 jamesfredley