Index: openacs-4/packages/acs-lang/lib/messages-to-translate.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/lib/messages-to-translate.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-lang/lib/messages-to-translate.adp 25 Sep 2003 16:20:15 -0000 1.1 @@ -0,0 +1,7 @@ + +
+ +

Translated messages on this page (@locale@)

+ +

+
Index: openacs-4/packages/acs-lang/lib/messages-to-translate.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/lib/messages-to-translate.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-lang/lib/messages-to-translate.tcl 25 Sep 2003 16:20:15 -0000 1.1 @@ -0,0 +1,53 @@ +set display_p [expr [lang::util::translator_mode_p] && ![string equal [ad_conn locale] "en_US"]] + +template::list::create \ + -name messages \ + -multirow messages \ + -elements { + message_key { + label "Message key" + } + orig_text { + label "English text" + } + translated_text { + label "Translation" + display_template { + + Translate + + + @messages.translated_text@ + + } + } + edit { + label "" + display_template { + + + Edit + + + } + sub_class narrow + } + } + +if { $display_p } { + multirow create messages message_key orig_text translated_text translate_url + + foreach message_key [lang::util::get_message_lookups] { + + set locale [ad_conn locale] + set orig_text [lang::message::lookup "en_US" $message_key] + set translated_text [lang::message::lookup $locale $message_key] + + set key_split [split $message_key "."] + set package_key_part [lindex $key_split 0] + set message_key_part [lindex $key_split 1] + set translate_url "/acs-lang/admin/edit-localized-message?[export_vars {{message_key $message_key_part} {package_key $package_key_part} locale}]" + + multirow append messages $message_key $orig_text $translated_text $translate_url + } +} 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.29 -r1.30 --- openacs-4/packages/acs-lang/tcl/lang-message-procs.tcl 24 Sep 2003 17:21:27 -0000 1.29 +++ openacs-4/packages/acs-lang/tcl/lang-message-procs.tcl 25 Sep 2003 16:20:15 -0000 1.30 @@ -362,18 +362,8 @@ } if { [lang::util::translator_mode_p] } { - # Translator mode - set up translate_url - - set key_split [split $key "."] - set package_key_part [lindex $key_split 0] - set message_key_part [lindex $key_split 1] - set return_url [ad_conn url] - if { [ns_getform] != "" } { - append return_url "?[export_entire_form_as_url_vars]" - } - - # return_url is already encoded and HTML quoted - set translate_url "/acs-lang/admin/edit-localized-message?[export_vars { { message_key $message_key_part } locale { package_key $package_key_part } return_url }]" + # Translator mode - record the message lookup + lang::util::record_message_lookup $key } # We remember the passed-in locale, because we want the translator mode to show which @@ -418,18 +408,6 @@ if { [llength $substitution_list] > 0 || ($upvar_level >= 1 && [string first "%" $message] != -1) } { set message [lang::message::format $message $substitution_list [expr $upvar_level + 1]] } - - if { [lang::util::translator_mode_p] } { - # Translator mode - return a translation link - if { [string equal $locale $org_locale] } { - # The message has been translated in the desired locale - append message "o" - } else { - # The translation is missing in the desired locale, make it yellow - set message "$message*" - - } - } return $message } Index: openacs-4/packages/acs-lang/tcl/lang-util-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/lang-util-procs.tcl,v diff -u -r1.21 -r1.22 --- openacs-4/packages/acs-lang/tcl/lang-util-procs.tcl 21 Aug 2003 08:45:26 -0000 1.21 +++ openacs-4/packages/acs-lang/tcl/lang-util-procs.tcl 25 Sep 2003 16:20:15 -0000 1.22 @@ -645,8 +645,41 @@ ad_set_client_property acs-lang translator_mode_p $translator_mode_p } +ad_proc -private lang::util::record_message_lookup { + message_key +} { + Record a message lookup in translator mode. In translator mode + we collect all message lookups at the bottom of the page for translation. + @author Peter Marklund +} { + global __lang_message_lookups + # Only makes sense to offer translation list if we're not in en_US locale + if { ![string equal [ad_conn locale] "en_US"] } { + if { ![info exists __lang_message_lookups] } { + lappend __lang_message_lookups $message_key + } elseif { [lsearch -exact $__lang_message_lookups $message_key] == -1 } { + lappend __lang_message_lookups $message_key + } + } +} + +ad_proc -private lang::util::get_message_lookups {} { + Get the list of all message keys looked up so far during the current + request. + + @author Peter Marklund +} { + global __lang_message_lookups + + if { [info exists __lang_message_lookups] } { + return $__lang_message_lookups + } else { + return {} + } +} + ##### # # Compatibility procs