Index: openacs-4/packages/acs-lang/www/admin/batch-editor.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/batch-editor.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-lang/www/admin/batch-editor.adp 12 Nov 2002 15:34:23 -0000 1.1 @@ -0,0 +1,27 @@ + + Localized Messages + @context_bar@ + +

You are editing locale: @locale_label@ [ @current_locale@ ]

+ + + + + + + + + + + + +
@pagination.text@ + + + + @pagination.text@ + +
+
+ + Index: openacs-4/packages/acs-lang/www/admin/batch-editor.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/batch-editor.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-lang/www/admin/batch-editor.tcl 12 Nov 2002 15:34:23 -0000 1.1 @@ -0,0 +1,106 @@ +ad_page_contract { + A quick and dirty batch editor for translation. + + @author Christian Hvid +} { + locales + package_key + {page_start 0} + {page_end 10} +} -properties { +} + +if { ![info exists locales] } { + set current_locale [ad_conn locale] +} else { + set current_locale $locales +} + +db_1row select_locale_lable { + select label as locale_label from ad_locales where locale = :current_locale +} + +set tab [ns_urlencode "localized-messages"] +set return_url "display-grouped-messages?tab=$tab&locales=$locales" +set context_bar [ad_context_bar [list $return_url Listing] "Batch Editor - $package_key"] + +form create batch_editor + +# export variables + +element create batch_editor locales -widget hidden -datatype text -value $locales +element create batch_editor package_key -widget hidden -datatype text -value $package_key +element create batch_editor page_start -widget hidden -datatype text -value $page_start +element create batch_editor page_end -widget hidden -datatype text -value $page_end + +# use a counter for pagination etc. +# this works with both oracle and postgresql + +set count 0 +set keys [list] + +db_foreach get_messages { + select lm1.message_key as message_key, + lm1.message as default_message + from lang_messages lm1 + where lm1.locale = 'en_US' and + lm1.package_key = :package_key + order by upper(lm1.message_key) +} { + lappend keys [string tolower $message_key] + + if {($count >= $page_start) && ($count < $page_end)} { + set translated_message "TRANSLATION MISSING" + db_0or1row get_translated_message { + select message as translated_message + from lang_messages + where package_key =:package_key and + message_key =:message_key and + locale =:current_locale + } + element create batch_editor "message_key_$count" -widget hidden -datatype text + element create batch_editor "message_key_info_$count" -widget inform -datatype text -label "key" + element create batch_editor "en_us_message_$count" -widget inform -datatype text -label "American" + element create batch_editor "message_$count" -widget textarea -datatype text -label $locale_label -html {cols 60 rows 4} + element set_properties batch_editor "message_key_$count" -value $message_key + element set_properties batch_editor "message_key_info_$count" -value "$message_key" + element set_properties batch_editor "en_us_message_$count" -value "[ad_quotehtml $default_message]" + if { [form is_request batch_editor] } { + element set_properties batch_editor "message_$count" -value $translated_message + } + } + + incr count +} + +set total $count + +# create pagination multiple + +multirow create pagination text hint url selected group +for {set count 0} {$count < $total} {incr count 10 } { + set end_page [expr $count + 9] + if { $end_page > [expr $total-1] } { + set end_page [expr $total-1] + } + if { ([string range [lindex $keys $count] 0 2] == "lt_") && ([string range [lindex $keys $end_page] 0 2] == "lt_") } { + set text "[string range [lindex $keys $count] 2 4] - [string range [lindex $keys $end_page] 2 4]" + } else { + set text "[string range [lindex $keys $count] 0 2] - [string range [lindex $keys $end_page] 0 2]" + } + multirow append pagination $text "[lindex $keys $count] - [lindex $keys $end_page]" "batch-editor?page_start=$count&page_end=[expr $count+10]&locales=$locales&package_key=$package_key" [expr $count == $page_start] [expr $count / 100] +} + +# is this a valid submit? then register the messages + +if { [form is_valid batch_editor] } { + for {set count $page_start} {($count < $page_end) && ($count < $total)} {incr count} { + # Register message via acs-lang + set message_key [element get_value batch_editor "message_key_$count"] + set message [element get_value batch_editor "message_$count"] + + if { $message != "TRANSLATION MISSING" } { + lang::message::register $locales $package_key $message_key $message + } + } +} Index: openacs-4/packages/acs-lang/www/admin/display-grouped-messages.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/Attic/display-grouped-messages.adp,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-lang/www/admin/display-grouped-messages.adp 4 Nov 2002 12:20:38 -0000 1.4 +++ openacs-4/packages/acs-lang/www/admin/display-grouped-messages.adp 12 Nov 2002 15:34:23 -0000 1.5 @@ -1,7 +1,7 @@ - + @page_title@ @context_bar@ - +

Your locale is @locale_label@ [ @current_locale@ ]

@@ -16,13 +16,56 @@ - + + +
+ + + + + +
All Packages
+ + + + +
+ + + + + + + + + + + +
PackageAction
@all_packages_group.package_key@ + (batch edit) + + (new) + +
+
+
+
+ + + + + + + + - + Index: openacs-4/packages/acs-lang/www/admin/display-localized-messages.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/Attic/display-localized-messages.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-lang/www/admin/display-localized-messages.tcl 25 Oct 2002 15:12:15 -0000 1.3 +++ openacs-4/packages/acs-lang/www/admin/display-localized-messages.tcl 12 Nov 2002 15:34:23 -0000 1.4 @@ -15,7 +15,15 @@ set tab [ns_urlencode "localized-messages"] set return_url "display-grouped-messages?tab=$tab&locales=$locales" -set context_bar [ad_context_bar [list $return_url Listing] "Messages"] + +if { ! $translated_p } { + set title "Edit Untranslated - $package_key" +} else { + set title "Edit Translated - $package_key" +} + +set context_bar [ad_context_bar [list $return_url Listing] $title] + set default_locale [ad_parameter DefaultLocale] set default_locale en_US @@ -41,6 +49,7 @@ lm1.message_key = lm2.message_key and lm1.package_key = lm2.package_key ) + order by upper(lm1.message_key) } # Query that get all the messages that HAVE a translation to @@ -56,18 +65,19 @@ lm2.locale = :current_locale and lm1.message_key = lm2.message_key and lm1.package_key = lm2.package_key + order by upper(lm1.message_key) } template::multirow create missing_translation message_key locale default_message escaped_key escaped_language template::multirow create translated_messages message_key locale default_message translated_message escaped_key escaped_language if { ! $translated_p } { db_foreach select_messages_not_translated $cat_msg_not_translated { - template::multirow append missing_translation $message_key $current_locale $default_message [ns_urlencode $message_key] [ns_urlencode $current_locale] + template::multirow append missing_translation $message_key $current_locale [ad_quotehtml $default_message] [ns_urlencode $message_key] [ns_urlencode $current_locale] } } else { db_foreach select_messages_translated $cat_msg_translated { - template::multirow append translated_messages $message_key $current_locale $default_message $translated_message [ns_urlencode $message_key] [ns_urlencode $current_locale] + template::multirow append translated_messages $message_key $current_locale [ad_quotehtml $default_message] [ad_quotehtml $translated_message] [ns_urlencode $message_key] [ns_urlencode $current_locale] } } Index: openacs-4/packages/acs-lang/www/admin/edit-localized-message.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/edit-localized-message.adp,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-lang/www/admin/edit-localized-message.adp 4 Nov 2002 12:20:38 -0000 1.4 +++ openacs-4/packages/acs-lang/www/admin/edit-localized-message.adp 12 Nov 2002 15:34:23 -0000 1.5 @@ -1,4 +1,4 @@ - + Edit a message @header_stuff@ @context_bar@ Index: openacs-4/packages/acs-lang/www/admin/edit-localized-message.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/edit-localized-message.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-lang/www/admin/edit-localized-message.tcl 25 Oct 2002 15:12:15 -0000 1.3 +++ openacs-4/packages/acs-lang/www/admin/edit-localized-message.tcl 12 Nov 2002 15:34:23 -0000 1.4 @@ -87,19 +87,15 @@ db_0or1row select_translated_message $sql_select_translated_message if { [exists_and_not_null translated_message] } { - - element set_properties message_editing message -value $translated_message - + element set_properties message_editing message -value [ad_quotehtml $translated_message] } else { - element set_properties message_editing message -value "No Translation Available" - } element set_properties message_editing message_key -value $message_key element set_properties message_editing package_key -value $package_key element set_properties message_editing locales -value $current_locale - element set_properties message_editing original_message -value $message + element set_properties message_editing original_message -value [ad_quotehtml $message] } else { Index: openacs-4/packages/acs-lang/www/admin/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/index.adp,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-lang/www/admin/index.adp 5 Nov 2002 14:52:07 -0000 1.4 +++ openacs-4/packages/acs-lang/www/admin/index.adp 12 Nov 2002 15:34:23 -0000 1.5 @@ -1,4 +1,4 @@ - + Administration of Localized Messages
+ + @@ -39,7 +82,7 @@
Need Translation
@missing_translation_group.package_key@ - (edit) + (edit untranslated) (new) @@ -58,7 +101,9 @@
- + + +
@@ -82,7 +127,7 @@
@translated_messages_group.package_key@ - (edit) + (edit translated) (new) @@ -104,4 +149,3 @@
- Index: openacs-4/packages/acs-lang/www/admin/display-grouped-messages.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/Attic/display-grouped-messages.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/acs-lang/www/admin/display-grouped-messages.tcl 25 Oct 2002 15:12:14 -0000 1.3 +++ openacs-4/packages/acs-lang/www/admin/display-grouped-messages.tcl 12 Nov 2002 15:34:23 -0000 1.4 @@ -22,6 +22,13 @@ set current_locale $locales } +# Query to get all packages that are prepared for translation + +set grouper_msg_all { + select distinct lm1.package_key + from lang_messages lm1 +} + # Query to get all the packages that have untranslated messages in the # selected locale @@ -51,6 +58,7 @@ lm1.package_key = lm2.package_key } +template::multirow create all_packages_group package_key package_key_encoded locale_encoded template::multirow create missing_translation_group package_key package_key_encoded locale_encoded template::multirow create translated_messages_group package_key package_key_encoded locale_encoded @@ -62,6 +70,10 @@ template::multirow append translated_messages_group $package_key [ns_urlencode $package_key] [ns_urlencode $current_locale] } +db_foreach select_messages_all_packages $grouper_msg_all { + template::multirow append all_packages_group $package_key [ns_urlencode $package_key] [ns_urlencode $current_locale] +} + db_1row select_locale_lable { select label as locale_label from ad_locales where locale = :current_locale } Index: openacs-4/packages/acs-lang/www/admin/display-localized-messages.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/www/admin/Attic/display-localized-messages.adp,v diff -u -r1.4 -r1.5 --- openacs-4/packages/acs-lang/www/admin/display-localized-messages.adp 4 Nov 2002 12:20:38 -0000 1.4 +++ openacs-4/packages/acs-lang/www/admin/display-localized-messages.adp 12 Nov 2002 15:34:23 -0000 1.5 @@ -1,4 +1,4 @@ - + Localized Messages @context_bar@ @@ -28,7 +28,7 @@
@missing_translation.message_key@ @missing_translation.default_message@Translation MissingTRANSLATION MISSING (edit)