lang::conn::browser_locale (private)
lang::conn::browser_locale
Defined in packages/acs-lang/tcl/locale-procs.tcl
Get the users preferred locale from the accept-language HTTP header.
- Returns:
- A locale or an empty string if no locale can be found that is supported by the system
- Authors:
- Lars Pind
- Peter Marklund
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- locale__test_lang_conn_browser_locale
Source code: set conn_locales [lang::conn::get_accept_language_header] set system_locales [lang::system::get_locales] foreach locale $conn_locales { regexp {^([^_]+)(?:_([^_]+))?$} $locale locale language region if { [info exists region] && $region ne "" } { # We have both language and region, e.g. en_US if {$locale in $system_locales} { # The locale was found in the system, a perfect match set perfect_match $locale break } else { # We don't have the full locale in the system but check if # we have a different locale with matching language, # i.e. a tentative match if { ![info exists tentative_match] } { set default_locale [lang::util::default_locale_from_lang $language] if { $default_locale ne "" } { set tentative_match $default_locale } } else { # We already have a tentative match with higher priority so # continue searching for a perfect match continue } } } else { # We have just a language, e.g. en set default_locale [lang::util::default_locale_from_lang $locale] if { $default_locale ne "" } { set perfect_match $default_locale break } } } if { [info exists perfect_match] && $perfect_match ne "" } { return $perfect_match } elseif { [info exists tentative_match] && $tentative_match ne "" } { return $tentative_match } else { # We didn't find a match return "" }XQL Not present: PostgreSQL, Oracle Generic XQL file: packages/acs-lang/tcl/locale-procs.xql