Index: openacs-4/packages/acs-lang/tcl/locale-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/locale-procs.tcl,v diff -u -r1.51.2.10 -r1.51.2.11 --- openacs-4/packages/acs-lang/tcl/locale-procs.tcl 16 Feb 2021 02:23:57 -0000 1.51.2.10 +++ openacs-4/packages/acs-lang/tcl/locale-procs.tcl 26 Nov 2021 13:10:01 -0000 1.51.2.11 @@ -514,15 +514,15 @@ # ##### -ad_proc -public lang::conn::locale { +ad_proc -private lang::conn::locale_not_cached { {-package_id ""} {-site_wide:boolean} {-user_id ""} } { Get the locale for this request, perhaps for a given package instance. - This procedure will never return an error. Everything that could fail is - wrapped in a catch. + This is the not-cached version. + @param package_id The package for which you want to get the locale. @param site_wide Set this if you want to get the site-wide locale. } { @@ -578,6 +578,28 @@ return $locale } +ad_proc -public lang::conn::locale { + {-package_id ""} + {-site_wide:boolean} + {-user_id ""} +} { + Get the locale for this request, perhaps for a given package instance. + + @param package_id The package for which you want to get the locale. + @param site_wide Set this if you want to get the site-wide locale. +} { + # Notice that caching for longer than the single request would be + # more complex, e.g. defaults coming from ad_conn in the various + # procs and flushing. + return [acs::per_request_cache eval \ + -key acs-lang.lang.conn.locale($package_id,$site_wide_p,$user_id) { + lang::conn::locale_not_cached \ + -package_id $package_id \ + -site_wide=$site_wide_p \ + -user_id $user_id + }] +} + ad_proc -private lang::conn::browser_locale {} { Get the users preferred locale from the accept-language HTTP header.