Forum OpenACS Development: Language auto-detection

Collapse
Posted by Daniël Mantione on
I've modified acs-lang a bit so that people can choose an option "Autodetect" (locale code: "auto") in the "Change Locale" page. If the locale is set to "Autodetect", lang::system::locale will read the Accept-Language header sent by the browser and search for a matching locale in the ad_locales table.

It is possible to set the system wide locale to "auto", so every visitor is greeted in his own language.

Where can I post a patch? What's prefered, a patch file, or the modified files?

Collapse
Posted by Jade Rubick on
Thanks, Daniel!

You can post a patch in the bug-tracker:

https://openacs.org/bugtracker/openacs/

Directions for posting are there in the patch section.

Collapse
Posted by Tilmann Singer on
The Accept-Language header is already considered when the user has not set another locale explicitely via /acs-lang/ - see packages/acs-lang/tcl/locale-procs.tcl. What exactly would be the difference when 'auto' could be selected explicitely?

(Speaking of 5.1 and HEAD)

Collapse
Posted by Daniël Mantione on
Ok, it's a bit late to discover that it already exists.

As far as I see, in the current implementation a browser locale allways overides the site-wide locale, while with the "auto" approach both the admin and the user would be free to use auto detection or not. The "auto" approach would make it also a bit easier to switch between settings for users, "Autodetect" appears in the list of locales so they can easily switch.

The current implementation is more refined than mine. Perhaps both implementations can be combined.