In a recent use case I came up with the need for having an explicit locale for not logged in users, overwriting the browsers default language (
https://openacs.org/forums/message-view?message_id=544412).
My proposal would be to write a procedure "lang::locale::set_cookie -locale" which will set a cookie "ad_lang_locale" to a certain locale for the user. Additionally write a procedure lang::locale::get_cookie which will retrieve the cookie's value.
lang::conn::locale would then be modified as per Gustaf's suggestion to first check if the user is logged in, then proceed as current. Afterwards, before checking the browser setting, it would try to retrieve the cookie and use the cookie's value (not the browser setting).
Once a user is registering, the locale to be stored in user_preferences will be taken from the cookie or the browser setting.
The question now is, should the cookie by cleared when the user registers or should it be reset when the locale of a user is changed. I would opt for the later as it would make sure the user is viewing the site even when not logged in, in the locale of his choosing.
But if we are keeping the cookie in sync with the locale of the user anyway, we could as well use the cookie instead of making a roundtrip to the database to figure out the user's locale. Then the cookie would be reset every time the user logs into the system.
For my use case it would be enough to implement only the first three paragraphs of this TIP (so no keeping in sync and rewrite of lang::conn:locale to first check the cookie and then the database), but I would like to hear first what others think how far the change should go. I will implement the changes accordingly for 5.4