Repository navigation
WW-3452 feat(text-provider): expand wildcard entries in struts.custom.i18n.resources - #552
Merged
Merged
Conversation
….i18n.resources Shows how an application can register every message bundle of a package with a "com.acme.messages.*" entry by overriding setCustomI18NResources in its own LocalizedTextProvider, without any framework change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relates to WW-3452
WW-3452 asks for
struts.custom.i18n.resourcesto accept entries such ascom.acme.messages.*. It will be closed in Struts as Won't Fix: classpath-scan order varies between containers and between jar orders, so when two matching bundles share a key the message shown could change between deployments. The ticket also leaves the pattern's meaning open (are sub-packages included? how do locale files fold back into a base name?).An application can already do this itself, and this example shows how.
WildcardLocalizedTextProvideroverridessetCustomI18NResourceswithout@Inject. The container already calls the method through the annotated parent, and annotating the override as well would inject it twice. Each.*entry is expanded withResourceFinderinto the bundles found directly in that package (not sub-packages). Locale variants such ascommon_plfold into their base bundle, and the names are sorted so lookup order is the same on every deployment.MyLocalizedTextProvidernow extends it, so the existing external-folder demo and the wildcard work together.org/apache/struts_example/messages/, wired instruts.xmland shown on the index page.Testing
WildcardLocalizedTextProviderTest(4 tests) failed against a stub without the override and passes with it. Making the locale-variant check always return false also breaks it.jetty:run: the index page renders all three wildcard keys, in Polish forAccept-Language: pl. Thesystemandfactorypages return 200 and the log shows no errors.WEB-INF/classes) were exercised.ResourceFinderhandles jar entries as well, but no test covers that path.🤖 Generated with Claude Code