Forum OpenACS Development: Re: Explicit locale for not logged in user

Collapse
Posted by Gustaf Neumann on

In XoWIKI ... categories ... still dependent on the browser setting (which may not be pl or ua by default).
if the package parameter use_connection_locale is set, the used locale depends on the browser setting or on the setting from /pvt/home.


Obviously I could rewrite the categories portlet to take the locale (explicitly like " -locale "en" ") and pass it the locale given by the URL.
you don't have to rewrite it, it is already implemented to behave so. You just have to pass in a locale (e.g. "en_US") and not a language prefix.

As you note, the problem exists mostly for users not logged in, since for others, one could alter the per-user settings in the database. On the other hand: a user perferring a certain language has most likely the browser set to his perferred language already, so the problem might in the real world not be so big. but what, if you have to implement a web-site with the language flags for not logged-in users due to a user-requirement - most likely your case.

you are only mentioning the categories. Don't you care as well for the message keys? If you care only about the categories, the simplest approach is to set a cookie and query this e.g. in the locale_clause in xowiki-portlet and make the setting e.g. cookie+default+system.

The generic solution is to alter ::lang::conn::locale to look additionally for locale-cookies. I would dicuss the specifics in a TIP, and specify the precedence and a simple API, ... and i would clear the cookie, if the locale is changed in /pvt/home. I think, this is a very reasonable extension.