Index: openacs-4/packages/xowiki/tcl/xowiki-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-procs.tcl,v diff -u -N -r1.542.2.82 -r1.542.2.83 --- openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 27 Aug 2020 16:07:44 -0000 1.542.2.82 +++ openacs-4/packages/xowiki/tcl/xowiki-procs.tcl 3 Sep 2020 13:41:16 -0000 1.542.2.83 @@ -4593,11 +4593,14 @@ } FormPage ad_instproc property { + {-localized false} name {default ""} } { Retrieve a FormPage property. + @param localized boolean flag telling that value should be passed + through localization @param name property name. Names starting with _ refer to object's members, rather than instance attributes. @param default fallback value when property is not set. @@ -4611,11 +4614,23 @@ set value [dict get ${:instance_attributes} $name] } + if {$localized} { + set locale [${:package_id} default_locale] + set value [lang::util::localize $value $locale] + } + return $value } + FormPage instproc build_property_message_key_name { + name + } { + return xowiki-${:item_id}-property-${name} + } + FormPage ad_instproc set_property { {-new 0} + {-localized false} name value } { @@ -4624,13 +4639,25 @@ @param new boolean flag telling if the property is new. Setting a value on a non-existing property without specifying this flag will result in an error. + @param localized boolean flag telling that provided value should + automatically be converted to a message key @param name property name. Names starting with _ indicate an object variable rather than a property stored in instance_attributes @param value property value - @return value + @return value (eventually converted to a has-notation message key) } { + if {$localized} { + if {![regexp [lang::util::message_key_regexp] $value]} { + set value [lang::util::convert_to_i18n \ + -locale [${:package_id} default_locale] \ + -object_id ${:item_id} \ + -message_key [:build_property_message_key_name $name] \ + -text $value] + } + } + if {[string match "_*" $name]} { set key [string range $name 1 end] @@ -4654,6 +4681,7 @@ FormPage ad_instproc get_property { -source -name:required + {-localized false} {-default ""} } { Retrieves a FormPage property @@ -4666,7 +4694,7 @@ } else { set page [:resolve_included_page_name $source] } - return [$page property $name $default] + return [$page property -localized $localized $name $default] } FormPage instproc lappend_property {name value} {