- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
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.
Defined in /var/www/openacs.org/packages/xowiki/tcl/form-field-procs.tcl
- See Also:
- lang::util::convert_to_i18n
Class Relations
- class: ::xotcl::Class
- superclass: ::xowiki::formfield::text
- subclass: ::xowiki::formfield::localized_richtext
::xotcl::Class create ::xowiki::formfield::localized_text \ -superclass ::xowiki::formfield::textMethods (to be applied on instances)
build_message_key_name (scripted)
# # Construct a per-item message key for this formfield # return xowiki-$object_id-formfield-${:name}convert_to_internal (scripted)
set value [:value] # # When the provided values does not look like a message key, then # create a new one on the fly. # #:log "localized_text sees <$value>" if {![regexp [lang::util::message_key_regexp] $value]} { set object_id [${:object} item_id] set package_id [${:object} package_id] # # Try to get the desired locale first from a form parameter with # a name suffix "__locale" or get the locale as specified by the user. # set locale [::$package_id form_parameter "${:name}__locale:token" [::$package_id default_locale]] # # Save the value in the message keys with the resulting 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)
# # Do NOT escape message keys (i.e. let them be rendered localized) # return $valuepretty_value (scripted)
# # Convert message keys to text so that e.g. wikicmds are # afterwards evaluated. # set locale [[${:object} package_id] default_locale] return [lang::util::localize $v $locale]render_input (scripted)
# # Rely on the superclass to do the right rendering of the main # content widget. # next # # Add a small selector for specifying the locale for the provided # message string. # 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} } }
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables