IIUC, the purpose is to split the page translation file, if it is too big
for being edited in a convenient way. For example, for a page
ProductDescription.java, having ProductDescription-Product1.properties,
ProductDescription-Product2.properties, etc..

To use the localisation support of tapestry, but using an arbitrary
property file as source of the message, you can do this that way :


    public class MyMessageBundle implements MessagesBundle {

        private String propertyName;

        public MyMessageBundle(String propertyName) {
            this.propertyName = propertyName;
        }

        public MessagesBundle getParent() {
            return rootBundle();
        }

        public Object getId() {
            return propertyName;
        }

        public Resource getBaseResource() {
            return new ClasspathResource("com/example/tapestry/pages/"
                    + propertyName);
        }
    }

    @Inject
    private ComponentMessagesSource componentMessagesSource;

    public String getMessage(String translationKey) {

        MessagesSource messagesSource = (MessagesSource)
componentMessagesSource
                .getInvalidationEventHub();

        MessagesBundle bundle = new
MyMessageBundle("ProductDescription-Product2");

        Messages messages = messagesSource.getMessages(bundle, locale);
        return messages.get(translationKey);
    }

It is the only way I've found now, and i discourage using that, because it
uses too many internal services that will maybe not present in the next
releases of Tapestry.

So the problem is not solved :-/

Regards,
Nicolas.


On Mon, 2 Aug 2010 23:07:46 -0700 (PDT), LeSanglier
<[email protected]> wrote:
> Okay,
> 
> But I don't want to use the Internationalization and localization
function,
> I would like something generic. Another example is to select a
description
> of a product from the properties : 
> product_1.properties
> product_2.properties
> product_3.properties.

-- 
Nicolas Bouillon
1 B rue de la fontaine
579702 Yutz
Tél: voir http://nicolas.bouillon.tel

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to