Class ::xowiki::formfield::localized_text
::xowiki::formfield::localized_text
create ...
This class can be used to provide an interface for specifying
internationalized text strings saved in message keys via input
from a form. When editing the content provided via the input field
is saved together with an item-specific message keys in the
message key tables via lang::util::convert_to_i18n.
This formfield class is especially useful for xowiki items which
have no language-prefix (e.g. folders or links). In other cases it
is probably still a better idea to create same named pages with
different language prefixes.
- See Also:
- lang::util::convert_to_i18n
Defined in /var/www/openacs/packages/xowiki/tcl/form-field-procs.tclClass Relations
- class: ::xotcl::Class
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- superclass: ::xowiki::formfield::text
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- subclass: ::xowiki::formfield::localized_richtext
![[i]](/resources/acs-subsite/ZoomIn16.gif)
::xotcl::Class create ::xowiki::formfield::localized_text \
-superclass ::xowiki::formfield::text
Methods (to be applied on instances)
build_message_key_name (scripted)
return xowiki-$object_id-formfield-${:name}convert_to_internal (scripted)
set value [:value]
if {![regexp [lang::util::message_key_regexp] $value]} {
set object_id [${:object} item_id]
set package_id [${:object} package_id]
set locale [::$package_id form_parameter "${:name}__locale:token" [::$package_id default_locale]]
set value [lang::util::convert_to_i18n -locale $locale -object_id $object_id -message_key [:build_message_key_name -object_id $object_id ${:name}] -text $value]
${:object} set_property -new 1 ${:name} $value
}escape_message_keys (scripted)
return $value
pretty_value (scripted)
set locale [[${:object} package_id] default_locale]
return [lang::util::localize $v $locale]render_input (scripted)
next
set value [[${:object} package_id] default_locale]
set :localizer_class locale-selector
set :localizer_id ${:id}__locale
set :localizer_name ${:name}__locale
set atts [:get_attributes disabled {localizer_class class} {localizer_id id} {localizer_name name}]
::html::select $atts {
foreach o [xowiki::locales] {
lassign $o label rep
set atts [list value $rep]
if {$rep in $value} {
lappend atts selected selected
}
::html::option $atts {::html::t $label}
}
}