Hey,

I'm now using my own implementation of AbstractMessages as I described in my previous mail. I do exactly the same as in MessagesImpl. The only difference is that I add something to the baseName argument used in ResourceBundle.getBundle(baseName, ...).

The selecting of the correct resource bundle works as it should, only now I'm experiencing something wrong with encoding. All my resource bundles have UTF-8 set as encoding (languages like German and French use characters that aren't supported by the default encoding). When using the binding prefix that I created which uses my implementation of AbstractMessages for some reason the special characters are not shown correctly as opposed to the regular binding prefix (${message: ... }).

Anyone an idea what could be happening here that in my implementation the files are not handled as UTF-8 encoded?

Nathan


On 12/08/15 16:37, Nathan Quirynen wrote:
Hi Thiago,

That's actually a clever solution, but seems a bit "hacky" and I'm not sure how it will also use the usual Index(_en).properties files?

I solved it at the moment with adding a new binding prefix where i pass the key and property value like following: ${messagebasedonpropertyvalue:messagekey=property} Then in the binding implementation I get the resourcebundle based on the property value and retrieve the message by given key.
This works as I hoped.

I am starting to doubt that having this many properties files for just 1 page/component is the way to go though. Maybe I'll have to move it to the database or somewhere else.

Thanks for your insight!

Nathan

On 11/08/15 16:33, Thiago H de Paula Figueiredo wrote:
On Tue, 11 Aug 2015 03:29:13 -0300, Nathan Quirynen <nat...@pensionarchitects.be> wrote:

So I want to have the usual properties file for the page and besides
this for each possible value of a property an extra properties files in
which specific localized messages are located.

So for example an Index page it can have the following:

- Index.properties
- Index_en.properties
- Index_120.properties
- Index_120_en.properties
- Index_130.properties
- Index_130_en.properties
- ...


But when the page loads the value of the property is for example 120
then Index.properties and Index_120.properties wil have to be used.

I hope it is more clear now. So i need to load the messages catalogs
depending on the property value.

I'd try this: @Inject ThreadLocale threadLocale, then in your page's onActivate() method call threadLocale(new Locale("[current language code]", [property value]), then use ${message:xxx} or @Inject Messages as usual. You'd need to revert the naming convention: instead of Index_130_en.properties, Index_en_130.properties. The idea is using locale country or even variant, as supported in Locale(String language, String country) and Locale(String language, String country, String variant) constructors of java.util.Locale.



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

Reply via email to