lang::user::set_locale (public)
lang::user::set_locale [ -package_id package_id ] [ -user_id user_id ] \ locale
Defined in packages/acs-lang/tcl/locale-procs.tcl
Set user locale setting for a given package instance.
- Switches:
- -package_id (optional)
- The package for which you want to set the locale setting, if you want to set it for a specific package, as opposed to a site-wide setting.
- -user_id (optional)
- Parameters:
- locale (required)
- The new locale that you want to use as your system locale.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- lang_test__lang_user_site_wide_locale, test_get_locales, create_form_with_numeric
Source code: if { $user_id eq "" } { set user_id [ad_conn user_id] } if { $user_id == 0 } { # Not logged in, use a cookie-based client locale set cookie_name [security::cookie_name locale] ad_set_cookie -replace t -max_age inf -samesite strict $cookie_name $locale # Flush the site-wide user preference cache util_memoize_flush [list lang::user::site_wide_locale_not_cached $user_id] return } if { $package_id eq "" } { # Set site-wide locale in user_preferences table db_dml set_user_site_wide_locale {} # Flush the site-wide user preference cache util_memoize_flush [list lang::user::site_wide_locale_not_cached $user_id] return } # The rest is for package level locale settings only # Even if package level locales are disabled, we'll still do this set user_locale_exists_p [db_string user_locale_exists_p {}] if { $user_locale_exists_p } { if { $locale ne "" } { db_dml update_user_locale {} } else { db_dml delete_user_locale {} } } else { if { $locale ne "" } { db_dml insert_user_locale {} } } # Flush the user locale preference cache util_memoize_flush [list lang::user::package_level_locale_not_cached $user_id $package_id]XQL Not present: PostgreSQL, Oracle Generic XQL file: <fullquery name="lang::user::set_locale.set_user_site_wide_locale"> <querytext> update user_preferences set locale = :locale where user_id = :user_id </querytext> </fullquery> <fullquery name="lang::user::set_locale.user_locale_exists_p"> <querytext> select count(*) from ad_locale_user_prefs where user_id = :user_id and package_id = :package_id </querytext> </fullquery> <fullquery name="lang::user::set_locale.update_user_locale"> <querytext> update ad_locale_user_prefs set locale = :locale where user_id = :user_id and package_id = :package_id </querytext> </fullquery> <fullquery name="lang::user::set_locale.insert_user_locale"> <querytext> insert into ad_locale_user_prefs (user_id, package_id, locale) values (:user_id, :package_id, :locale) </querytext> </fullquery> <fullquery name="lang::user::set_locale.delete_user_locale"> <querytext> delete from ad_locale_user_prefs where user_id = :user_id and package_id = :package_id </querytext> </fullquery>packages/acs-lang/tcl/locale-procs.xql