Forum OpenACS Q&A: util_memoize-ing locales

Collapse
Posted by Samer Abukhait on
Hello,
I am facing a weird problem
On an openACS instance (5.0.4 on aol 4.01 on oracle 10g)
The default locale is set to en_US, BUT
[util_memoize [list lang::user::site_wide_locale_not_cached $user_id] [sec_session_timeout]]
returns AR_LB (The other enabled locale on the system) for not-logged in members.

I tested [lang::user::site_wide_locale_not_cached 0] It returns en_US
Also, after invoking util_memoize_flush [list lang::user::site_wide_locale_not_cached $user_id]
[util_memoize [list lang::user::site_wide_locale_not_cached $user_id] [sec_session_timeout]] returns en_US

This is a permanent problem, after a while the problem returns back!
Any idea why this could happen??
Collapse
Posted by Nis Jørgensen on
The source looks like this:

if { $user_id == 0 } {
  set locale [ad_get_cookie "ad_locale"]
  if { [empty_string_p $locale] } {
    set locale [lang::system::site_wide_locale]
  }

  return $locale
    } else {
        return [db_string get_user_site_wide_locale {} -default ""]
    }

So the return value depends on a cookie. Not a good idea to cache this.

Collapse
Posted by Kevin Lau on
Dear Samer and All,

I have faced the similar problem of Samer.

I am building a tri-lingual sites (English, Traditional Chinese and Simplified Chinese). Mostly, it works fine.

But occassionally, the language would not be changed when we selected other language. To change lange, we would use the URL like this:
/acs-lang/change-locale?user_locale=zh_TW&return_url=/return/path

I read the code and have similar behaviour like Samer's case. How can I fix this problem?

Thank you very much

Kevin