lang::message::check (public)
lang::message::check locale package_key message_key message
Defined in packages/acs-lang/tcl/lang-message-procs.tcl
Check a message for semantic and sanity correctness (usually called just before a message is registered). Throws an error when one of the checks fails.
- Parameters:
- locale (required)
- package_key (required)
- message_key (required)
- message (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- lang_messages_correct
Source code: # Qualify the locale variable value with a country code if it is # just a language if { [string length $locale] == 2 } { # It seems to be a language (iso codes are 2 characters) # We don't do a more throughout check since this is not # invoked by users. # let's get the default locale for that language set locale [lang::util::default_locale_from_lang $locale] } # Create a globally (across packages) unique key for the cache set key "${package_key}.${message_key}" # Check that non-en_US messages don't have invalid embedded variables # Exclude the special case of datetime configuration messages in acs-lang. An alternative # to treating those messages as a special case here would be to have those messages use # quoted percentage signs (double percentage signs). if { $locale ne "en_US" && ![regexp {^acs-lang\.localization-} $key] } { set embedded_vars [get_embedded_vars $message] set embedded_vars_en_us [get_embedded_vars [lang::message::lookup en_US $key {} {} 0]] set missing_vars [util_get_subset_missing $embedded_vars $embedded_vars_en_us] if { [llength $missing_vars] > 0 } { set msg "Message key '$key' in locale '$locale' has these embedded variables not present in the en_US locale: [join $missing_vars ","]." ad_log error $msg error $msg } } # If a localization key from acs-lang... if {[regexp {^acs-lang\.localization-(.*)$} $key match lc_key]} { # # ...number separators for decimal and thousands must be # checked to ensure they are not equal, otherwise the # localized number parsing will fail. # if {$lc_key in {decimal_point thousands_sep mon_thousands_sep}} { # # Fetch values in case there were already loaded. # foreach k {decimal_point thousands_sep mon_thousands_sep} { set $k [expr {[lang::message::message_exists_p $locale acs-lang.localization-$k] ? [lc_get -locale $locale $k] : ""}] } # # Overwrite the fetched value with the provided one. # set $lc_key $message # # We require, that the decimal_point was either provided # or loaded before to be able to compare it with the # thousands points. # if {$decimal_point ne "" && [string first $decimal_point "$thousands_sep$mon_thousands_sep"] > -1} { error "locale $locale, key: $key: Message keys for thousands and decimal separators must be different." } } }Generic XQL file: packages/acs-lang/tcl/lang-message-procs.xql
PostgreSQL XQL file: packages/acs-lang/tcl/lang-message-procs-postgresql.xql
Oracle XQL file: packages/acs-lang/tcl/lang-message-procs-oracle.xql