You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by t5_lothar <lo...@gmx.de> on 2010/07/07 18:51:15 UTC

Re: [T5] How to "skin" .properties files? Localization almost good...

This approach sounds really promising and works out well for templates. But
how about properties? As the author said, something similiar can be used for
properties. However, I have difficulties in finding the equivalent...


Andreas Pardeike-2 wrote:
> 
> On 5 mar 2008, at 06.46, Vjeran Marcinko wrote:
> 
>> Anyway, sometimes I deploy my Tapestry application to various  
>> customers which want to have dfferent text messages or maybe even  
>> outlook of some pages. I can use CSS for some of it, but lets say  
>> that I want to pick different page/global .property file for  
>> displaying different messages stored in them.
>>
>> Actually, perfect solution for me would be some kindof Locale which  
>> could be set initially through Tapestry configuration, so I could  
>> have smething like:
>>
>> Home.html
>> Home_customer1.html
>> Home_customer2.html
> 
> I would solve this by defining my own PageTemplateLocator (and similar  
> for
> properties too). It would need a service 'YourCustomerMode' which  
> would be
> inserted into the template constructor:
> 
> First, in AppModule.java:
> 
> public PageTemplateLocator buildMyPageLocator(
> 	@ContextProvider AssetFactory contextAssetFactory,
> 	ComponentClassResolver componentClassResolver,
> 	YourCustomerMode customer) {
> 		return new MyTemplateLocator(contextAssetFactory.getRootResource(),  
> componentClassResolver, customer);
> }
> 	
> public static void contributeAliasOverrides(
> 	@InjectService("MyPageLocator") PageTemplateLocator locator,
> 	Configuration<AliasContribution<PageTemplateLocator>> configuration) {
> 		 
> configuration.add(AliasContribution.create(PageTemplateLocator.class,  
> locator));
> }
> 
> and the MyTemplateLocator.java:
> 
> public class MyTemplateLocator implements PageTemplateLocator
> {
> 	private final Resource _contextRoot;
> 	private final ComponentClassResolver _resolver;
> 	private final YourCustomerMode _customerMode;
> 	
> 	public MyTemplateLocator(Resource contextRoot, ComponentClassResolver  
> resolver, YourCustomerMode customerMode)
> 	{
> 		_contextRoot = contextRoot;
> 		_resolver = resolver;
> 		_ customerMode = customerMode;
> 	}
> 	
> 	public Resource findPageTemplateResource(ComponentModel model, Locale  
> locale)
> 	{
> 		String className = model.getComponentClassName();
> 		if(!className.contains(".pages."))
> 			return null;
> 		
> 		String logicalName =  
> _resolver.resolvePageClassNameToPageName(className);
> 		int slashx = logicalName.lastIndexOf('/');
> 		if(slashx > 0)
> 		{
> 			String simpleClassName = InternalUtils.lastTerm(className);
> 			logicalName = logicalName.substring(0, slashx + 1) + simpleClassName;
> 		}
> 		
> 		String path = format("%s_%s.html", logicalName,  
> _customerMode.getCurrentCustomerName());
> 		return _contextRoot.forFile(path).forLocale(locale);
> 	}
> }
> 
> // Andreas Pardeike
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/-T5--How-to-%22skin%22-.properties-files--Localization-almost-good...-tp15843698p29098637.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] How to "skin" .properties files? Localization almost good...

Posted by "Juan E. Maya" <ma...@gmail.com>.
we had to do something similar and at the end we decided to create a
new binder prefix "branding" and use the brand associated to the
request to retrieve a label from a property file, appending the
property label to the key. So for example:

if we want to print the  title in english for client 1. we do:
${branding:title}. In the .properties there must exist a label for the
given branding. For example:
title-client1=The title for the client one.

On Wed, Jul 7, 2010 at 11:04 PM, Christophe Cordenier
<ch...@gmail.com> wrote:
> Hi
>
> Actually locale are made of three elements a language, a country and a
> variant. Maybe you can set a variant per customer...
>
> 2010/7/7 t5_lothar <lo...@gmx.de>
>
>>
>> This approach sounds really promising and works out well for templates. But
>> how about properties? As the author said, something similiar can be used
>> for
>> properties. However, I have difficulties in finding the equivalent...
>>
>>
>> Andreas Pardeike-2 wrote:
>> >
>> > On 5 mar 2008, at 06.46, Vjeran Marcinko wrote:
>> >
>> >> Anyway, sometimes I deploy my Tapestry application to various
>> >> customers which want to have dfferent text messages or maybe even
>> >> outlook of some pages. I can use CSS for some of it, but lets say
>> >> that I want to pick different page/global .property file for
>> >> displaying different messages stored in them.
>> >>
>> >> Actually, perfect solution for me would be some kindof Locale which
>> >> could be set initially through Tapestry configuration, so I could
>> >> have smething like:
>> >>
>> >> Home.html
>> >> Home_customer1.html
>> >> Home_customer2.html
>> >
>> > I would solve this by defining my own PageTemplateLocator (and similar
>> > for
>> > properties too). It would need a service 'YourCustomerMode' which
>> > would be
>> > inserted into the template constructor:
>> >
>> > First, in AppModule.java:
>> >
>> > public PageTemplateLocator buildMyPageLocator(
>> >       @ContextProvider AssetFactory contextAssetFactory,
>> >       ComponentClassResolver componentClassResolver,
>> >       YourCustomerMode customer) {
>> >               return new
>> MyTemplateLocator(contextAssetFactory.getRootResource(),
>> > componentClassResolver, customer);
>> > }
>> >
>> > public static void contributeAliasOverrides(
>> >       @InjectService("MyPageLocator") PageTemplateLocator locator,
>> >       Configuration<AliasContribution<PageTemplateLocator>>
>> configuration) {
>> >
>> > configuration.add(AliasContribution.create(PageTemplateLocator.class,
>> > locator));
>> > }
>> >
>> > and the MyTemplateLocator.java:
>> >
>> > public class MyTemplateLocator implements PageTemplateLocator
>> > {
>> >       private final Resource _contextRoot;
>> >       private final ComponentClassResolver _resolver;
>> >       private final YourCustomerMode _customerMode;
>> >
>> >       public MyTemplateLocator(Resource contextRoot,
>> ComponentClassResolver
>> > resolver, YourCustomerMode customerMode)
>> >       {
>> >               _contextRoot = contextRoot;
>> >               _resolver = resolver;
>> >               _ customerMode = customerMode;
>> >       }
>> >
>> >       public Resource findPageTemplateResource(ComponentModel model,
>> Locale
>> > locale)
>> >       {
>> >               String className = model.getComponentClassName();
>> >               if(!className.contains(".pages."))
>> >                       return null;
>> >
>> >               String logicalName =
>> > _resolver.resolvePageClassNameToPageName(className);
>> >               int slashx = logicalName.lastIndexOf('/');
>> >               if(slashx > 0)
>> >               {
>> >                       String simpleClassName =
>> InternalUtils.lastTerm(className);
>> >                       logicalName = logicalName.substring(0, slashx + 1)
>> + simpleClassName;
>> >               }
>> >
>> >               String path = format("%s_%s.html", logicalName,
>> > _customerMode.getCurrentCustomerName());
>> >               return _contextRoot.forFile(path).forLocale(locale);
>> >       }
>> > }
>> >
>> > // Andreas Pardeike
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://old.nabble.com/-T5--How-to-%22skin%22-.properties-files--Localization-almost-good...-tp15843698p29098637.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
> --
> Regards,
> Christophe Cordenier.
>
> Committer on Apache Tapestry 5
> Co-creator of wooki @wookicentral.com
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] How to "skin" .properties files? Localization almost good...

Posted by Christophe Cordenier <ch...@gmail.com>.
Hi

Actually locale are made of three elements a language, a country and a
variant. Maybe you can set a variant per customer...

2010/7/7 t5_lothar <lo...@gmx.de>

>
> This approach sounds really promising and works out well for templates. But
> how about properties? As the author said, something similiar can be used
> for
> properties. However, I have difficulties in finding the equivalent...
>
>
> Andreas Pardeike-2 wrote:
> >
> > On 5 mar 2008, at 06.46, Vjeran Marcinko wrote:
> >
> >> Anyway, sometimes I deploy my Tapestry application to various
> >> customers which want to have dfferent text messages or maybe even
> >> outlook of some pages. I can use CSS for some of it, but lets say
> >> that I want to pick different page/global .property file for
> >> displaying different messages stored in them.
> >>
> >> Actually, perfect solution for me would be some kindof Locale which
> >> could be set initially through Tapestry configuration, so I could
> >> have smething like:
> >>
> >> Home.html
> >> Home_customer1.html
> >> Home_customer2.html
> >
> > I would solve this by defining my own PageTemplateLocator (and similar
> > for
> > properties too). It would need a service 'YourCustomerMode' which
> > would be
> > inserted into the template constructor:
> >
> > First, in AppModule.java:
> >
> > public PageTemplateLocator buildMyPageLocator(
> >       @ContextProvider AssetFactory contextAssetFactory,
> >       ComponentClassResolver componentClassResolver,
> >       YourCustomerMode customer) {
> >               return new
> MyTemplateLocator(contextAssetFactory.getRootResource(),
> > componentClassResolver, customer);
> > }
> >
> > public static void contributeAliasOverrides(
> >       @InjectService("MyPageLocator") PageTemplateLocator locator,
> >       Configuration<AliasContribution<PageTemplateLocator>>
> configuration) {
> >
> > configuration.add(AliasContribution.create(PageTemplateLocator.class,
> > locator));
> > }
> >
> > and the MyTemplateLocator.java:
> >
> > public class MyTemplateLocator implements PageTemplateLocator
> > {
> >       private final Resource _contextRoot;
> >       private final ComponentClassResolver _resolver;
> >       private final YourCustomerMode _customerMode;
> >
> >       public MyTemplateLocator(Resource contextRoot,
> ComponentClassResolver
> > resolver, YourCustomerMode customerMode)
> >       {
> >               _contextRoot = contextRoot;
> >               _resolver = resolver;
> >               _ customerMode = customerMode;
> >       }
> >
> >       public Resource findPageTemplateResource(ComponentModel model,
> Locale
> > locale)
> >       {
> >               String className = model.getComponentClassName();
> >               if(!className.contains(".pages."))
> >                       return null;
> >
> >               String logicalName =
> > _resolver.resolvePageClassNameToPageName(className);
> >               int slashx = logicalName.lastIndexOf('/');
> >               if(slashx > 0)
> >               {
> >                       String simpleClassName =
> InternalUtils.lastTerm(className);
> >                       logicalName = logicalName.substring(0, slashx + 1)
> + simpleClassName;
> >               }
> >
> >               String path = format("%s_%s.html", logicalName,
> > _customerMode.getCurrentCustomerName());
> >               return _contextRoot.forFile(path).forLocale(locale);
> >       }
> > }
> >
> > // Andreas Pardeike
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/-T5--How-to-%22skin%22-.properties-files--Localization-almost-good...-tp15843698p29098637.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Regards,
Christophe Cordenier.

Committer on Apache Tapestry 5
Co-creator of wooki @wookicentral.com