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.36 -r1.36.2.1 --- openacs-4/packages/acs-lang/tcl/lang-util-procs.tcl 27 Feb 2005 22:45:39 -0000 1.36 +++ openacs-4/packages/acs-lang/tcl/lang-util-procs.tcl 25 Aug 2005 14:28:36 -0000 1.36.2.1 @@ -754,3 +754,56 @@ } } +ad_proc -public lang::util::convert_to_i18n { + {-locale} + {-package_key "acs-translations"} + {-message_key ""} + {-prefix ""} + {-text:required} +} { + Internationalising of Attributes. This is done by storing the attribute with it's acs-lang key +} { + + # If the package acs-translations is installed do the conversion + # magic, otherwise just return the text again. + + if {[apm_package_id_from_key acs-translations]} { + if {[empty_string_p $message_key]} { + if {[empty_string_p $prefix]} { + # Having no prefix or message_key is discouraged as it + # might have interesting side effects due to double + # meanings of the same english string in multiple contexts + # but for the time being we should still allow this. + set message_key [lang::util::suggest_key $text] + } else { + set message_key "${prefix}_[lang::util::suggest_key $text]" + } + } + + # Register the language keys + lang::message::register en_US $package_key $message_key $text + if {[exists_and_not_null locale]} { + lang::message::register $locale $package_key $message_key $text + } + + return "#${package_key}.${message_key}#" + } else { + return "$text" + } +} + +ad_proc -public lang::util::localize_list_of_lists { + {-list} +} { + localize the elements of a list_of_lists +} { + set list_output [list] + foreach item $list { + set item_output [list] + foreach part $item { + lappend item_output [lang::util::localize $part] + } + lappend list_output $item_output + } + return $list_output +}