| |
754 |
754 |
set language [lindex [split $locale "_"] 0] |
| |
755 |
755 |
set locale [lang::util::default_locale_from_lang $language] |
| |
756 |
756 |
if { [message_exists_p $locale $key] } { |
| |
757 |
757 |
set message [nsv_get lang_message_$locale $key] |
| |
758 |
758 |
} else { |
| |
759 |
759 |
# Trying system locale for package (or site-wide) |
| |
760 |
760 |
set locale [lang::system::locale] |
| |
761 |
761 |
if { [message_exists_p $locale $key] } { |
| |
762 |
762 |
set message [nsv_get lang_message_$locale $key] |
| |
763 |
763 |
} else { |
| |
764 |
764 |
# Trying site-wide system locale |
| |
765 |
765 |
set locale [lang::system::locale -site_wide] |
| |
766 |
766 |
if { [message_exists_p $locale $key] } { |
| |
767 |
767 |
set message [nsv_get lang_message_$locale $key] |
| |
768 |
768 |
} else { |
| |
769 |
769 |
# Resorting to en_US |
| |
770 |
770 |
set locale "en_US" |
| |
771 |
771 |
if { [message_exists_p $locale $key] } { |
| |
772 |
772 |
set message [nsv_get lang_message_$locale $key] |
| |
773 |
773 |
} else { |
| |
|
774 |
if {"TRANSLATION MISSING" != $default} { |
| |
|
775 |
set message $default |
| |
|
776 |
} else { |
| |
774 |
777 |
if {[string match "acs-translations.*" $key]} { |
| |
775 |
778 |
ns_log Debug "lang::message::lookup: Key '$key' does not exist in en_US" |
| |
776 |
779 |
set message "MESSAGE KEY MISSING: '$key'" |
| |
777 |
780 |
} else { |
| |
778 |
781 |
ns_log Error "lang::message::lookup: Key '$key' does not exist in en_US" |
| |
779 |
782 |
set message "MESSAGE KEY MISSING: '$key'" |
| |
780 |
783 |
} |
| |
781 |
784 |
} |
| |
782 |
785 |
} |
| |
783 |
786 |
} |
| |
784 |
787 |
} |
| |
785 |
788 |
} |
| |
|
789 |
} |
| |
786 |
790 |
|
| |
787 |
791 |
# Do any variable substitutions (interpolation of variables) |
| |
788 |
792 |
# Set upvar_level to 0 and substitution_list empty to prevent substitution from happening |
| |
789 |
793 |
if { [llength $substitution_list] > 0 || ($upvar_level >= 1 && [string first "%" $message] != -1) } { |
| |
790 |
794 |
set message [lang::message::format $message $substitution_list [expr {$upvar_level + 1}]] |
| |
791 |
795 |
} |
| |
792 |
796 |
|
| |
793 |
797 |
if { [lang::util::translator_mode_p] } { |
| |
794 |
798 |
# Translator mode - record the message lookup |
| |
795 |
799 |
lang::util::record_message_lookup $key |
| |
796 |
800 |
|
| |
797 |
801 |
if { $translator_mode_p } { |
| |
798 |
802 |
global message_key_num |
| |
799 |
803 |
if { ![info exists message_key_num] } { |
| |
800 |
804 |
set message_key_num 1 |
| |
801 |
805 |
} else { |
| |
802 |
806 |
incr message_key_num |
| |
803 |
807 |
} |
| |
804 |
808 |
|
| |
805 |
809 |
# encode the key in the page |