You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Christoph Jäger <ch...@polleninfo.org> on 2010/02/05 00:33:03 UTC

Tapestry i18n t:Label

Hi,

I have a multi-language Tapestry5 application. I have several  
properties files containing the translations, with quite a few entries  
already, and still growing.

Now, each time I use a t:Label on some form, I need to add a property  
like "name-label" or "address-label" to these translation files,  
although they already contain a property like "name" or "address".  
This gives a lot of redundant entries in my properties files.  
Alternatively I can use <t:Label for="name">${message:name}</t:Label>,  
and have only one entry in my properties file, but increase the amount  
of text needed in the template files.

It would be a great help, if t:Label would first search for a property  
like "name-label", and, if none is found, for "name" (without the  
trailing "-label").

Is there a good reason not to enhance t:Label to do this? How can I  
help to get this implemented (in case I am not the only one who thinks  
this would be a good idea)?

Best Regards,

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


Re: Tapestry i18n t:Label

Posted by Christoph Jäger <ch...@polleninfo.org>.
Hi Alexander,

thanks for your hint, I'll try this tomorrow (also need to go to bed :).

Christoph

On Feb 5, 2010, at 23:45 , Alexander Muthmann wrote:

>
>> Is there a good reason not to enhance t:Label to do this? How can I  
>> help to get this implemented (in case I am not the only one who  
>> thinks this would be a good idea)?
>
> Hi Christoph,
>
> one solution could be, to override the whole  
> ComponentDefaultProvider . You could use the implementation, which  
> comes with the tapestry source and modify the method defaultLabel to  
> the following:
>
> public String defaultLabel(ComponentResources resources)
>    {
>        Defense.notNull(resources, "resources");
>
>        String componentId = resources.getId();
>        String key = componentId + "-label";
>
>        Messages containerMessages =  
> resources.getContainerResources().getMessages();
>
>        if (containerMessages.contains(key)) return  
> containerMessages.get(key);
>       \\Try without -label
> if (containerMessages.contains(componentId)) return  
> containerMessages.get(componentId);
>        return TapestryInternalUtils.toUserPresentable(componentId);
> }
>
> then you have to contribute this method in you appmodule:
>
> public static void  
> contributeComponentDefaultProvider(MappedConfiguration<Class,Object>  
> config){
>        config.add(ComponentDefaultProvider.class,  
> MyComponentDefaultProviderImpl());
> }
>
> Sorry for not testing this, but have to go to bed now ;)
>
> Greetings
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


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


Re: Tapestry i18n t:Label

Posted by Alexander Muthmann <am...@dev-eth0.de>.
> Is there a good reason not to enhance t:Label to do this? How can I 
> help to get this implemented (in case I am not the only one who thinks 
> this would be a good idea)?

Hi Christoph,

one solution could be, to override the whole ComponentDefaultProvider . 
You could use the implementation, which comes with the tapestry source 
and modify the method defaultLabel to the following:

public String defaultLabel(ComponentResources resources)
     {
         Defense.notNull(resources, "resources");

         String componentId = resources.getId();
         String key = componentId + "-label";

         Messages containerMessages = 
resources.getContainerResources().getMessages();

         if (containerMessages.contains(key)) return 
containerMessages.get(key);
        \\Try without -label
if (containerMessages.contains(componentId)) return 
containerMessages.get(componentId);
         return TapestryInternalUtils.toUserPresentable(componentId);
  }

then you have to contribute this method in you appmodule:

public static void 
contributeComponentDefaultProvider(MappedConfiguration<Class,Object> 
config){
         config.add(ComponentDefaultProvider.class, 
MyComponentDefaultProviderImpl());
}

Sorry for not testing this, but have to go to bed now ;)

Greetings


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


Re: Tapestry i18n t:Label

Posted by kamiseq <ka...@gmail.com>.
hi,
it is good idea but recently I was thinking more about the functionality
that you can have a special marker or global function that gets String and
then tapestry will produce properties file for you and replace those
markers/function with ${message:whatever} so it can be easily translated.

from my point of view every text in the view that need to be translated
needs its own unique identifier and I dont really care if this descriptive
name or just a number. even if now I have 2 label with the same text it
doesnt mean it will not change in the future.

I think it would be really nice to see a text in tml file rather than
${message:aName}

pozdrawiam
Paweł Kamiński

kamiseq@gmail.com
pkaminski.prv@gmail.com
______________________


On 5 February 2010 00:39, Thiago H. de Paula Figueiredo
<th...@gmail.com>wrote:

> On Thu, 04 Feb 2010 21:33:03 -0200, Christoph Jäger <
> christoph.jaeger@polleninfo.org> wrote:
>
>  Hi,
>>
>
> Hi!
>
>
>  It would be a great help, if t:Label would first search for a property
>> like "name-label", and, if none is found, for "name" (without the trailing
>> "-label").
>>
>
> This logic is implemented in the ComponentDefaultProvider service,
> specifically its defaultLabel(ComponentResources resources) method. You can
> advise it so it uses any logic you want.
>
>
>  Is there a good reason not to enhance t:Label to do this? How can I help
>> to get this implemented (in case I am not the only one who thinks this would
>> be a good idea)?
>>
>
> I think it could be a good idea. Please post a JIRA for that.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, software architect and developer, Ars Machina Tecnologia da
> Informação Ltda.
> http://www.arsmachina.com.br
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Tapestry i18n t:Label

Posted by Christoph Jäger <ch...@polleninfo.org>.
Hi,

I posted JIRA TAP5-1003.

On Feb 5, 2010, at 00:39 , Thiago H. de Paula Figueiredo wrote:

> On Thu, 04 Feb 2010 21:33:03 -0200, Christoph Jäger <christoph.jaeger@polleninfo.org 
> > wrote:
>
>> Hi,
>
> Hi!
>
>> It would be a great help, if t:Label would first search for a  
>> property like "name-label", and, if none is found, for  
>> "name" (without the trailing "-label").
>
> This logic is implemented in the ComponentDefaultProvider service,  
> specifically its defaultLabel(ComponentResources resources) method.  
> You can advise it so it uses any logic you want.

Can you point me some documentation or example where I can learn about  
this?

Thanks,

Christoph Jäger

>
>> Is there a good reason not to enhance t:Label to do this? How can I  
>> help to get this implemented (in case I am not the only one who  
>> thinks this would be a good idea)?
>
> I think it could be a good idea. Please post a JIRA for that.
>
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant,  
> developer, and instructor
> Owner, software architect and developer, Ars Machina Tecnologia da  
> Informação Ltda.
> http://www.arsmachina.com.br


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


Re: Tapestry i18n t:Label

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 04 Feb 2010 21:33:03 -0200, Christoph Jäger  
<ch...@polleninfo.org> wrote:

> Hi,

Hi!

> It would be a great help, if t:Label would first search for a property  
> like "name-label", and, if none is found, for "name" (without the  
> trailing "-label").

This logic is implemented in the ComponentDefaultProvider service,  
specifically its defaultLabel(ComponentResources resources) method. You  
can advise it so it uses any logic you want.

> Is there a good reason not to enhance t:Label to do this? How can I help  
> to get this implemented (in case I am not the only one who thinks this  
> would be a good idea)?

I think it could be a good idea. Please post a JIRA for that.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

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