Skip to content

WW-3452 feat(text-provider): expand wildcard entries in struts.custom.i18n.resources - #552

Merged
lukaszlenart merged 1 commit into
mainfrom
WW-3452-wildcard-i18n-resources
Oct 10, 2026
Merged

lukaszlenart merged 1 commit into
mainfrom
WW-3452-wildcard-i18n-resources

Conversation

@lukaszlenart

Copy link
Copy Markdown
Member

Relates to WW-3452

WW-3452 asks for struts.custom.i18n.resources to accept entries such as com.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.

  • WildcardLocalizedTextProvider overrides setCustomI18NResources without @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 with ResourceFinder into the bundles found directly in that package (not sub-packages). Locale variants such as common_pl fold into their base bundle, and the names are sorted so lookup order is the same on every deployment.
  • MyLocalizedTextProvider now extends it, so the existing external-folder demo and the wildcard work together.
  • Three demo bundles under org/apache/struts_example/messages/, wired in struts.xml and 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 for Accept-Language: pl. The system and factory pages return 200 and the log shows no errors.
  • Only directory classpath entries (WEB-INF/classes) were exercised. ResourceFinder handles jar entries as well, but no test covers that path.

🤖 Generated with Claude Code

….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>
@lukaszlenart
lukaszlenart marked this pull request as ready for review October 10, 2026 12:36
@lukaszlenart
lukaszlenart merged commit 3bbb0a9 into main Oct 10, 2026
2 checks passed
@lukaszlenart
lukaszlenart deleted the WW-3452-wildcard-i18n-resources branch October 10, 2026 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant