Issue Details (XML | Word | Printable)

Key: TAPESTRY-881
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Jesse Kuhnert
Reporter: Matt Raible
Votes: 1
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
Tapestry

Allow global i18n bundle location to be customized

Created: 10/Mar/06 10:58 PM   Updated: 05/Mar/07 02:33 AM
Return to search
Component/s: Framework
Affects Version/s: 4.1.1
Fix Version/s: 4.1.2

Time Tracking:
Not Specified

Resolution Date: 05/Mar/07 02:33 AM


 Description  « Hide
The current mechanism for specifying a global i18n resource bundle is not very flexible.

http://jakarta.apache.org/tapestry/UsersGuide/localization.html#localization.namespace

It requires you to name your i18n bundles the same as your .application file. Furthermore, it requires that your bundles be places in the WEB-INF directory. Most other web frameworks (and Java applications in general) require you to have the ResourceBundle somewhere in your classpath (generally in the root - WEB-INF/classes).

1. I think the root of the classpath should be the default location - even if you're using the ".application name matches i18n name" mechanism.
2. It should be possible to customize the name of the file. Possibly something like the following in your .application file:

<property name="org.apache.tapestry.global-properties" value="ApplicationResources"/> -> points to WEB-INF/classes/ApplicationResources.properties (and others with _locale.properties
<property name="org.apache.tapestry.global-properties" value="com.myapplication.web.messages"/> - points to /WEB-INF/classes/com/myapplication/web/messages.properties

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Andreas Andreou made changes - 09/May/06 04:26 PM
Field Original Value New Value
Component/s Web [ 11285 ]
Component/s Framework [ 11280 ]
Jesse Kuhnert made changes - 13/Sep/06 09:42 PM
Assignee Jesse Kuhnert [ jkuhnert ]
Jesse Kuhnert added a comment - 18/Nov/06 09:48 PM
Hope you're happy... ;)

Documentation is coming as well, but the new meta configurable property name is "org.apache.tapestry.namespace-properties-name".

The classpath is search by default in addition to WEB-INF/ for the application spec file as well.

Jesse Kuhnert made changes - 18/Nov/06 09:48 PM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Fix Version/s 4.1.1 [ 12312021 ]
Repository Revision Date User Message
ASF #476615 Sat Nov 18 21:50:21 UTC 2006 jkuhnert Resolves TAPESTRY-881. Added ability to define alternate .properties file names on namespace specifications.

Also added behavior making ApplicationSpecificationInitializer look in the classpath as well as context
path for an app spec by default.
Files Changed
MODIFY /tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/integration/JettyRunner.java
MODIFY /tapestry/tapestry4/trunk/pom.xml
ADD /tapestry/tapestry4/trunk/tapestry-framework/src/test/Fred.application
ADD /tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/WEB-INF/i18n.application
MODIFY /tapestry/tapestry4/trunk/tapestry-examples/Workbench/src/context/WEB-INF/workbench.application
ADD /tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/WEB-INF
ADD /tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/integration/i18n/TestI18nResources.java
ADD /tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n
MODIFY /tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ApplicationSpecificationInitializer.java
MODIFY /tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/TestApplicationSpecificationInitializer.java
ADD /tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/WEB-INF/web.xml
MODIFY /tapestry/tapestry4/trunk/tapestry-framework/pom.xml
ADD /tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/WEB-INF/random.properties
MODIFY /tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/wml/Go.java
ADD /tapestry/tapestry4/trunk/tapestry-framework/src/test-data/i18n/Home.html
ADD /tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/integration/i18n
MODIFY /tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentMessagesSourceImpl.java

Matt Raible added a comment - 18/Nov/06 09:53 PM
I'm happy all right! We're should I send the Guinness to? If it's fixed in 4.1.1, do you have a target date for this release? Since I'm all Maven-2-repo-ed these days, I'm more interested in when it'll hit a repo. Thanks Jesse!

Jesse Kuhnert added a comment - 18/Nov/06 09:59 PM
Heh. It should be out in about an hour. I still need to update the docs and then deploy. (An hour is probably longer than I'll need but better to be safe I guess..)

Matt Raible added a comment - 29/Dec/06 01:36 AM
I'm using 4.1.1 (downloaded it today) and this doesn't seem to work. In my .application file I have:

<meta key="org.apache.tapestry.namespace-properties-name" value="ApplicationResources"/>

And in src/main/resources, I have a bunch of ApplicationResources*.properties i18n bundles. SiteMesh seems to work fine at resolving the locale, but Tapestry shows things like:

[MAINMENU.HEADING]

[MAINMENU.MESSAGE]

Any ideas?

Jesse Kuhnert made changes - 29/Dec/06 05:05 AM
Status Resolved [ 5 ] Reopened [ 4 ]
Resolution Fixed [ 1 ]
Jesse Kuhnert made changes - 29/Dec/06 05:05 AM
Fix Version/s 4.1.2 [ 12312202 ]
Affects Version/s 4.0 [ 10794 ]
Fix Version/s 4.1.1 [ 12312021 ]
Affects Version/s 4.1.1 [ 12312021 ]
Matt Raible added a comment - 03/Jan/07 06:11 PM
Is it possible to add the ability to support multiple global bundles? I'd like to have a messages.properties for labels, messages and such and an errors.properties for validation errors.

Example:

<meta key="org.apache.tapestry.namespace-properties-name" value="messages,errors"/>

Mike Perham added a comment - 17/Jan/07 07:46 PM
I just ran into this too. I guess I have to separate my java l10n and my tapestry l10n. :(

Mike Perham added a comment - 17/Jan/07 07:49 PM
Note this is only true in the war's application. For code packaged as a tapestry library in a separate jar, you can share the l10n files. It's only Tapestry 4.0's insistence on using servlet context resources with the appliction that causes a problem.

Matt Raible added a comment - 24/Jan/07 06:08 AM
Is there a timeline on the 4.1.2 release? Or maybe getting this fixed in a snapshot release? We're hoping to release AppFuse 2.0 in the next few weeks and w/o this fix, our Tapestry support is not as good as I'd like it to be. Currently, we have duplicate i18n files (in WEB-INF for Tapestry and WEB-INF/classes for SiteMesh and tests).

Jesse Kuhnert added a comment - 24/Jan/07 06:48 AM
I hadn't noticed these messages before sorry. Assuming I don't have any local pending changes (I don't think I do) I'll fix this next. (which means this week for sure)

Matt Raible added a comment - 13/Feb/07 04:53 PM
Any update on this? Also, will this feature be in Tapestry 5?

Jesse Kuhnert added a comment - 04/Mar/07 05:28 PM
I think I'm going to need a more specific example of exactly where these Properties files are located when the application is running.

Matt Raible added a comment - 04/Mar/07 06:57 PM
Most web frameworks load i18n bundles from the classpath, just like a regular ol' ResourceBundle. With JSP/JSTL, JSF, Struts 1/2 and Spring MVC, my resource bundles are located in WEB-INF/classes.

Right now, Tapestry allows a global (single) ResourceBundle, but the name must match the name of the ApplicationServlet and it must be located in the WEB-INF directory. I'd like to customize both the name and location - so I can load ApplicationResources*.properties from WEB-INF/classes.

Jesse Kuhnert added a comment - 04/Mar/07 07:04 PM
So....are talking about directly in the literal path WEB-INF/classes/ApplicationResources<foo>.properties or is there a more elegant solution others are using? Doesn't seem very hard to support this, just need to make sure I know exactly what is expected.

Matt Raible added a comment - 04/Mar/07 07:27 PM
Yes, that's exactly what I'm talking about - I'm not looking for a more elegant solution at this point. However, most frameworks allow global bundles to be anywhere in the classpath.

Jesse Kuhnert added a comment - 04/Mar/07 07:49 PM
Anywhere in the classpath so long as you specify where or literally "Foo.properties" will be found no matter where you stick it in the classpath?

Matt Raible added a comment - 04/Mar/07 11:42 PM
So as long as you specify where. For example:

ApplicationResources -> WEB-INF/classes/ApplicationResources.properties, as well as any other locales (ApplicationResources_es.properties, etc)
com.foo.ApplicationResources > WEB-INF/classes/com/foo/ApplicationResources.properties (as well as other locales)

Repository Revision Date User Message
ASF #514527 Mon Mar 05 02:32:50 UTC 2007 jkuhnert Fixes TAPESTRY-881. Allow for more flexible resolution of properties bundles by searching / handling classpath versions
of the resources for those instances where the spec resource location only resolves to context relative paths.
Files Changed
MODIFY /tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ClasspathResourceFactoryImpl.java
ADD /tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/override.properties
MODIFY /tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ApplicationSpecificationInitializer.java
DEL /tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/WEB-INF/Home.properties
MODIFY /tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/services/impl/TestNamespaceResources.java
ADD /tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/mock/app/impl/classpath.properties
MODIFY /tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/pom.xml
ADD /tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/main/resources/messages.properties
MODIFY /tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/impl/ComponentMessagesSourceImpl.java
MODIFY /tapestry/tapestry4/trunk/tapestry-framework/src/test/org/apache/tapestry/junit/TestComponentMessages.java
MODIFY /tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/WEB-INF/timetracker.application

Jesse Kuhnert added a comment - 05/Mar/07 02:33 AM
Sheww...Ok everything works as requested now, besides multiple message property names.

Jesse Kuhnert made changes - 05/Mar/07 02:33 AM
Status Reopened [ 4 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]