lang::conn::get_accept_language_header (private)
lang::conn::get_accept_language_header
Defined in packages/acs-lang/tcl/locale-procs.tcl
Obtain a list of locals from the request headers.
- Returns:
- a list of locales in the syntax used by OpenACS (ISO codes)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: set acclang [ns_set iget [ns_conn headers] "Accept-Language"] # Split by comma, and get rid of any ;q=0.5 parts # acclang is something like 'da,en-us;q=0.8,es-ni;q=0.5,de;q=0.3' set acclangv [list] foreach elm [split $acclang ","] { # Get rid of trailing ;q=0.5 part and trim spaces set elm [string trimleft [lindex [split $elm ";"] 0] " "] # Ignore the default catchall setting "*" if {$elm eq "*"} { continue } # elm is now either like 'da' or 'en-us' # make it into something like 'da' or 'en_US' set elmv [split $elm "-"] set elm [lindex $elmv 0] if { [llength $elmv] > 1 } { append elm "_[string toupper [lindex $elmv 1]]" } if {[lang::conn::valid_locale_p $elm]} { lappend acclangv $elm } else { # It is usually bots or other kinds of not-canonical web # browsers which set this wrong. We tolerate it by # assuming our default language. ns_log warning "Invalid locale '$elm' in provided Accept-Language header field. Defaulting to system locale." return [lang::system::locale] } } return $acclangvXQL Not present: PostgreSQL, Oracle Generic XQL file: packages/acs-lang/tcl/locale-procs.xql