Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tapestry : Start page use english locale instead of default locale

We built a website with Tapestry 5.1.0.5 and we encounter, sometimes, a missing key problem when we hit the start-page.

This problem appeared only 4 times, this is a random issue.

Actual configuration:

  • configuration.add(SymbolConstants.SUPPORTED_LOCALES, "fr"); => so the default local is fr and not en

  • configuration.add("tapestry.start-page-name", "Accueil"); => so when we hit / tapestry redirects us on /accueil

Here is the problem we sometimes see:

When hitting / tapestry searches keys in *_en.properties instead of *_fr.properties but if we hit /accueil tapestry searches keys in *_fr.properties.

Trace log :

Caused by: java.lang.NumberFormatException: For input string: **"[[missing key: prehome.store.opening.delay]]"**
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
        at java.lang.Integer.parseInt(Integer.java:447)
        at java.lang.Integer.parseInt(Integer.java:497)
        at XXXXXXX.tapestry.components.overlayer.StoreOverlayer.initStoresAndRegions(StoreOverlayer.java:652)
        at XXXXXXX.tapestry.components.overlayer.StoreOverlayer.setupRender(StoreOverlayer.java)
        at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.invokeComponent(ComponentPageElementImpl.java:184)
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.run(ComponentPageElementImpl.java:164)
        at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:933)
        ... 94 more

01-02-2012 11:55:52:979 23120252 ERROR org.apache.tapestry5.internal.services.InternalModule.PagePool  - Page Page[Accueil en] is dirty, and will be discarded (rather than returned to the page pool).

Has anyone had this problem?

Do you know why when we hit the start-page, tapestry use en locale instead of our default locale fr?

like image 611
Fabien Avatar asked Feb 09 '12 15:02

Fabien


1 Answers

I'd say that if you want to ensure that default locale is French, then just rename all message_fr.properties to message.properties.

Also please take a look into browser settings. If your browser is requesting English version of the site, then Tapestry obeys. You may override that behavior, but I'd suggest treating that like a feature (as user is getting site related to his preference) rather than a bug.

And last hint, if you are supporting more than one language then list them all in supported locales constant.

-= Edit =- it's also probably worth checking do you have the global messages.properties file in English or in French

like image 90
Michal Gruca Avatar answered Oct 19 '22 03:10

Michal Gruca