apache / apache/grails-core

resourcebundle basenames order not respected

Open
#11,795 2 comments 0 reactions 0 assignees Claimed by @jdaugherty View on GitHub
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

### 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

Contributor guide

Open the contributing guide

Research direction

Start with the PluginAwareResourceBundleMessageSource configuration in resources.groovy and reproduce the basename-order case using the linked example application. Review pull request #14753 and verify that bundles are checked in the declared order, with an earlier basename overriding later keys; confirm the behavior against the issue's translation scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy, spring
Domain
backend, internationalization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.