Index: openacs-4/packages/acs-lang/tcl/lang-message-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/lang-message-procs.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-lang/tcl/lang-message-procs.tcl 21 Oct 2002 11:39:12 -0000 1.4 +++ openacs-4/packages/acs-lang/tcl/lang-message-procs.tcl 23 Oct 2002 11:49:18 -0000 1.5 @@ -167,6 +167,9 @@ interface. This allows a translator to work from the context of a web page. @param locale Locale (e.g., "en_US") or language (e.g., "en") string. + If locale is the empty string ad_conn locale will be used + if we are in an HTTP connection, otherwise the system locale + (SiteWideLocale) will be used. @param key Unique identifier for this message. Will be the same identifier for each locale. All keys belong to a certain package and should be prefixed with the package key of that package @@ -192,7 +195,20 @@ # Peter TODO: add translation links # Peter TODO/FIXME: Should we prefix with ad_conn package_key if the lookup fails? - set default_locale [parameter::get -package_id [apm_package_id_from_key acs-lang] -parameter SiteWideLocale] + set system_locale [parameter::get -package_id [apm_package_id_from_key acs-lang] -parameter SiteWideLocale] + + # Set default locale if none was provided + if { [empty_string_p $locale] } { + + global ad_conn + if { [info exists ad_conn] } { + # We are in an HTTP connection (request) so use that locale + set locale [ad_conn locale] + } else { + # There is no HTTP connection - resort to system locale + set locale $system_locale + } + } if { [string length $locale] == 2 } { @@ -341,7 +357,7 @@ @see lang::message::lookup } { switch [llength $args] { - 1 { return [lang::message::lookup [ad_conn locale] [lindex $args 0] "TRANSLATION MISSING"] } + 1 { return [lang::message::lookup "" [lindex $args 0] "TRANSLATION MISSING"] } 2 { return [lang::message::lookup [lindex $args 0] [lindex $args 1] "TRANSLATION MISSING"] } 3 { return [lang::message::lookup [lindex $args 0] [lindex $args 1] [lindex $args 2]] } 4 { return [lang::message::lookup [lindex $args 0] [lindex $args 1] [lindex $args 2] [lindex $args 3]] }