Re: [T5] Adding/removing entries to messages

2010-02-07 Thread Alexander Muthmann
Sorry, I missed the point, my solution only works for labels used in 
grids etc


On 06.02.2010 13:51, Nuno Ferreira wrote:

I'll definitely try that. And using a cache I could give my users the
functionality to change at runtime the label translations, which I'm
planning anyway since google translate isn't always perfect.


On 6 February 2010 12:19, Alexander Muthmannamuthm...@dev-eth0.de  wrote:

   

Fast idea:
You could override the existing provider for Message-Entries and add a
function to look at google translate if the requestes label was not found.
The service would be ComponentDefaultProvider and the needed method
defaultLabel:

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);

\\here you can check google translate

return TapestryInternalUtils.toUserPresentable(componentId);
  }

On the marked position you could add a new cache for already used labels...



On 06.02.2010 13:12, Nuno Ferreira wrote:

 

Hi,

I would like to know if there is a way to programatically add and remove
an
entry from a messages catalog.

The only way I see how to do this is to write to the file
app_{locale}.properties, but I would like a cleaner way if there is one.

I want to use google translate to automatically fill every catalog, and
would love to hear there is something like
messages.add(translation,locale)
:)

Thanks in advance,
Nuno Ferreira



   

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


 
   


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



[T5] Adding/removing entries to messages

2010-02-06 Thread Nuno Ferreira
Hi,

I would like to know if there is a way to programatically add and remove an
entry from a messages catalog.

The only way I see how to do this is to write to the file
app_{locale}.properties, but I would like a cleaner way if there is one.

I want to use google translate to automatically fill every catalog, and
would love to hear there is something like messages.add(translation,locale)
:)

Thanks in advance,
Nuno Ferreira


Re: [T5] Adding/removing entries to messages

2010-02-06 Thread Alexander Muthmann

Fast idea:
You could override the existing provider for Message-Entries and add a 
function to look at google translate if the requestes label was not found.
The service would be ComponentDefaultProvider and the needed method 
defaultLabel:


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);


\\here you can check google translate

return TapestryInternalUtils.toUserPresentable(componentId);
 }

On the marked position you could add a new cache for already used labels...


On 06.02.2010 13:12, Nuno Ferreira wrote:

Hi,

I would like to know if there is a way to programatically add and remove an
entry from a messages catalog.

The only way I see how to do this is to write to the file
app_{locale}.properties, but I would like a cleaner way if there is one.

I want to use google translate to automatically fill every catalog, and
would love to hear there is something like messages.add(translation,locale)
:)

Thanks in advance,
Nuno Ferreira

   


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



Re: [T5] Adding/removing entries to messages

2010-02-06 Thread Nuno Ferreira
I'll definitely try that. And using a cache I could give my users the
functionality to change at runtime the label translations, which I'm
planning anyway since google translate isn't always perfect.


On 6 February 2010 12:19, Alexander Muthmann amuthm...@dev-eth0.de wrote:

 Fast idea:
 You could override the existing provider for Message-Entries and add a
 function to look at google translate if the requestes label was not found.
 The service would be ComponentDefaultProvider and the needed method
 defaultLabel:

 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);

\\here you can check google translate

return TapestryInternalUtils.toUserPresentable(componentId);
  }

 On the marked position you could add a new cache for already used labels...



 On 06.02.2010 13:12, Nuno Ferreira wrote:

 Hi,

 I would like to know if there is a way to programatically add and remove
 an
 entry from a messages catalog.

 The only way I see how to do this is to write to the file
 app_{locale}.properties, but I would like a cleaner way if there is one.

 I want to use google translate to automatically fill every catalog, and
 would love to hear there is something like
 messages.add(translation,locale)
 :)

 Thanks in advance,
 Nuno Ferreira




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