edit-localized-message.tcl
Displays the localized message from the database for translation (displays an individual message)
- Location:
- /packages/acs-lang/www/admin/edit-localized-message.tcl
- Authors:
- Bruno Mattarollo
- Christian Hvid
- Created:
- 30 October 2001
- CVS ID:
$Id: edit-localized-message.tcl,v 1.26 2024/09/11 06:15:48 gustafn Exp $
Related Files
- packages/acs-lang/www/admin/edit-localized-message.tcl
- packages/acs-lang/www/admin/edit-localized-message.adp
[ hide source ] | [ make this the default ]
File Contents
ad_page_contract { Displays the localized message from the database for translation (displays an individual message) @author Bruno Mattarollo <bruno.mattarollo@ams.greenpeace.org> @author Christian Hvid @creation-date 30 October 2001 @cvs-id $Id: edit-localized-message.tcl,v 1.26 2024/09/11 06:15:48 gustafn Exp $ } { locale:word package_key:token message_key:token show:word,optional {usage_p:boolean,notnull "f"} {return_url:localurl {}} } if { [string length $locale] == 2 } { # Only language provided, let's get the default locale for this language set default_locale [lang::util::default_locale_from_lang $locale] if { $default_locale eq "" } { error "Could not look up locale for language $locale" } else { set locale $default_locale } } # We rename to avoid conflict in queries set current_locale $locale set default_locale en_US set locale_label [lang::util::get_label $current_locale] set default_locale_label [lang::util::get_label $default_locale] set page_title "Edit $package_key.$message_key" set context [list [list [export_vars -base package-list { locale }] $locale_label] \ [list [export_vars -no_empty -base message-list { locale package_key show }] $package_key] \ "$package_key.$message_key"] # We let you create/delete messages keys if you're in the default locale set create_p [string equal $current_locale $default_locale] set description_edit_url [export_vars -no_empty -base edit-description { locale package_key message_key show }] set default_locale_edit_url [export_vars -base edit-localized-message { {locale $default_locale} package_key message_key return_url }] set usage_hide_url [export_vars -no_empty -base [ad_conn url] { locale package_key message_key show return_url }] set usage_show_url [export_vars -no_empty -base [ad_conn url] { locale package_key message_key show {usage_p 1} return_url }] set delete_url [export_vars -no_empty -base message-delete { locale package_key message_key show {return_url {[ad_return_url]}} }] set undelete_url [export_vars -no_empty -base message-undelete { locale package_key message_key show {return_url {[ad_return_url]}} }] set unregister_url [export_vars -no_empty -base message-unregister { locale package_key message_key show {return_url {[ad_return_url]}} }] set deleted_p [db_string get_deleted_p { select deleted_p from lang_messages where package_key = :package_key and message_key = :message_key and locale = :current_locale } -default false] ad_form -name message_form -form { {locale:text(hidden),optional {value $current_locale}} {package_key:text(hidden),optional {value $package_key}} {message_key:text(hidden),optional {value $message_key}} {show:text(hidden),optional} {return_url:text(hidden),optional {value $return_url}} {message_key_pretty:text(inform) {label "Message Key"} {value "$package_key.$message_key"} } {description:text(inform),optional {label "Description"} {mode display} {after_html {(<a href='[ns_quotehtml $description_edit_url]'>Edit</a>)}} } } if { $default_locale ne $current_locale } { ad_form -extend -name message_form -form { {original_message:text(inform) {label "$default_locale_label Message"} {after_html {(<a href="[ns_quotehtml $default_locale_edit_url]">Edit</a>)}} } } } ad_form -extend -name message_form -form { {message:text(textarea),optional {label "$locale_label Message"} {html { rows 6 cols 40 } } } {comment:text(textarea),optional {label "Comment"} {html { rows 6 cols 40 }} } {submit:text(submit) {label " Update "} } } -on_request { set original_message {} set description {} db_0or1row select_original_message { select lm.message as original_message, lmk.description from lang_messages lm, lang_message_keys lmk where lm.message_key = lmk.message_key and lm.package_key = lmk.package_key and lm.package_key = :package_key and lm.message_key = :message_key and lm.locale = :default_locale } set translated_p [db_0or1row select_translated_message { select lm.message as message, cu.first_names || ' ' || cu.last_name as creation_user_name, cu.user_id as creation_user_id, to_char(lm.creation_date, 'YYYY-MM-DD') as creation_date from lang_messages lm, cc_users cu where lm.package_key = :package_key and lm.message_key = :message_key and lm.locale = :current_locale and cu.user_id = lm.creation_user }] if { [info exists message] } { set message $message } else { set message $original_message } set original_message [ns_quotehtml $original_message] set description "[ad_text_to_html -- $description]" # Augment the audit trail with info on who created the first message if { $current_locale ne $default_locale && $translated_p } { set edited_p [db_string edit_count { select count(*) from lang_messages_audit where package_key = :package_key and message_key = :message_key and locale = :current_locale }] if { $edited_p } { # The translation has been edited # Get the creation user of the first revision db_1row select_first_revision { select cu.first_names || ' ' || cu.last_name as creation_user_name, cu.user_id as creation_user_id, to_char(lma.overwrite_date, 'YYYY-MM-DD') as creation_date from lang_messages_audit lma, cc_users cu where lma.package_key = :package_key and lma.message_key = :message_key and lma.locale = :current_locale and cu.user_id = lma.overwrite_user and lma.audit_id = (select min(lm2.audit_id) from lang_messages_audit lm2 where lm2.package_key = :package_key and lm2.message_key = :message_key and lm2.locale = :current_locale ) } } set first_translated_message [subst { <ul> <li>First translated by [acs_community_member_link -user_id $creation_user_id -label $creation_user_name] on $creation_date </li></ul> }] } else { set first_translated_message "" } } -on_submit { set first_translated_message "" ad_try { # Call semantic and sanity checks on the key before registering. lang::message::check $locale $package_key $message_key $message } on error {errorMsg} { template::form::set_error message message $errorMsg break } # Register message via acs-lang lang::message::register -comment $comment $locale $package_key $message_key $message if { $return_url eq "" } { set return_url [export_vars -no_empty -base [ad_conn url] { locale package_key message_key show }] } ad_returnredirect $return_url ad_script_abort } # Local variables: # mode: tcl # tcl-indent-level: 4 # indent-tabs-mode: nil # End: