[prev in list] [next in list] [prev in thread] [next in thread]
List: tapestry-user
Subject: Re: Single-file Localization data
From: Dave Smith <dizzyd () gmail ! com>
Date: 2004-10-29 22:45:04
Message-ID: cba01a4104102915454723d7eb () mail ! gmail ! com
[Download RAW message or body]
Done. The attached patch now causes a global properties file to be
loaded and included in each page's potential message properties.
The properties file needs to be in the same directory as
<AppName>.application and should be called: <AppName>.properties or
<AppName>_<Locale>.properties. I don't _think_ this conflicts with
anything, since an application can't have its own .properties file at
this time.
Please let me know if there's anything additional I need to do to get
this patch accepted.
Also, is there a release policy for including small patches like this?
It'd be nice not to have to use my own patched copy forever.. :)
Thanks,
D.
On Fri, 29 Oct 2004 16:14:13 -0400, Erik Hatcher
<erik@ehatchersolutions.com> wrote:
>
>
>
> On Oct 29, 2004, at 3:52 PM, Dave Smith wrote:
> > Is there an accepted way to pull l10n strings out of a single file
> > instead of a file per page? Seems like I could plugin my own
> > IComponentMessagesSource, but wanted to see if there is a more
> > frameworky way to about it. :)
>
> There currently is not a built-in way to do this, unfortunately. It
> would be nice if the default implementation supported a global file to
> use as a fall-back. In my last project, message resources were pulled
> from a database so I did not have an incentive to implement this in the
> default .properties mechanism.
>
> It would be trivial to do, though. So if you do this, feel free to fix
> the default implementation and submit a patch back.
>
> Erik
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
["global.patch" (text/x-patch)]
--- tmp/Tapestry-3.0.1/framework/src/org/apache/tapestry/engine/DefaultComponentMessagesSource.java 2004-10-16 \
18:39:21.000000000 -0600
+++ src/Tapestry-3.0.1/framework/src/org/apache/tapestry/engine/DefaultComponentMessagesSource.java 2004-10-29 \
16:28:28.798976960 -0600 @@ -26,9 +26,11 @@
import org.apache.commons.logging.LogFactory;
import org.apache.tapestry.ApplicationRuntimeException;
import org.apache.tapestry.IComponent;
+import org.apache.tapestry.IEngine;
import org.apache.tapestry.IMessages;
import org.apache.tapestry.IResourceLocation;
import org.apache.tapestry.Tapestry;
+import org.apache.tapestry.spec.IApplicationSpecification;
import org.apache.tapestry.util.MultiKey;
/**
@@ -47,6 +49,8 @@
private Properties _emptyProperties = new Properties();
+ private Properties _globalProperties;
+
/**
* Map of {@link Properties}, keyed on a {@link MultiKey} of
* component specification path and locale.
@@ -73,6 +77,16 @@
component.getSpecification().getSpecificationLocation();
Locale locale = component.getPage().getLocale();
+ // Attempt to load global properties
+ if (_globalProperties == null)
+ {
+ IEngine engine = component.getPage().getEngine();
+ IResourceLocation appLocation =
+ engine.getSpecification().getSpecificationLocation();
+
+ _globalProperties = assembleProperties(appLocation, locale);
+ }
+
// Check to see if already in the cache
MultiKey key = buildKey(specificationLocation, locale);
@@ -112,7 +126,7 @@
if (parent == null)
{
- parent = readProperties(baseResourceLocation, baseName, null, null);
+ parent = readProperties(baseResourceLocation, baseName, null, \
_globalProperties);
if (parent == null)
parent = _emptyProperties;
@@ -233,6 +247,7 @@
public void reset()
{
_cache.clear();
+ _globalProperties = null;
}
public IMessages getMessages(IComponent component)
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic