[ 
https://issues.apache.org/jira/browse/WW-3452?focusedWorklogId=1046780&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1046780
 ]

ASF GitHub Bot logged work on WW-3452:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 10/Oct/26 12:34
            Start Date: 10/Oct/26 12:34
    Worklog Time Spent: 10m 
      Work Description: lukaszlenart opened a new pull request, #552:
URL: https://github.com/apache/struts-examples/pull/552

   Relates to [WW-3452](https://issues.apache.org/jira/browse/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](https://claude.com/claude-code)




Issue Time Tracking
-------------------

            Worklog Id:     (was: 1046780)
    Remaining Estimate: 3h 50m  (was: 4h)
            Time Spent: 10m

> let struts.custom.i18n.resources supports wildcard
> --------------------------------------------------
>
>                 Key: WW-3452
>                 URL: https://issues.apache.org/jira/browse/WW-3452
>             Project: Struts 2
>          Issue Type: Improvement
>            Reporter: Yanming Zhou
>            Priority: Major
>              Labels: message, resource
>             Fix For: 7.5.0
>
>   Original Estimate: 4h
>          Time Spent: 10m
>  Remaining Estimate: 3h 50m
>
> {code:xml}
> <constant name="struts.custom.i18n.resources" 
> value="resources.i18n.messages,com.acme.messages.*" />
> {code}
> following code is my uncompleted patch,I want to know how to scan wildcard 
> resources using xwork/struts2 util class.
> org.apache.struts2.config.BeanSelectionProvider  line:245
> {code:java}
>         
> LocalizedTextUtil.addDefaultResourceBundle("org/apache/struts2/struts-messages");
>         String bundles = 
> props.getProperty(StrutsConstants.STRUTS_CUSTOM_I18N_RESOURCES);
>         if (bundles != null && bundles.length() > 0) {
>             StringTokenizer customBundles = new 
> StringTokenizer(props.getProperty(StrutsConstants.STRUTS_CUSTOM_I18N_RESOURCES),
>  ", ");
>             while (customBundles.hasMoreTokens()) {
>                 String name = customBundles.nextToken();
>                 // add start
>                 if(name.contains("*")){
>                       Collection<String> resources = new HashSet<String>(); 
> //TODO scan resources from classpath
>                       for(String res : resources)
>                               try {
>                             LOG.info("Loading global messages from " + res);
>                             LocalizedTextUtil.addDefaultResourceBundle(res);
>                         } catch (Exception e) {
>                             LOG.error("Could not find messages file " + res + 
> ".properties. Skipping");
>                         }
>                         continue;
>                 }
>                 // add end
>                 try {
>                     LOG.info("Loading global messages from " + name);
>                     LocalizedTextUtil.addDefaultResourceBundle(name);
>                 } catch (Exception e) {
>                     LOG.error("Could not find messages file " + name + 
> ".properties. Skipping");
>                 }
>             }
>         }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to