Author: richter
Date: Thu Oct 4 07:43:55 2007
New Revision: 581932
URL: http://svn.apache.org/viewvc?rev=581932&view=rev
Log:
- Support for internationalization in Emberl::Form
Modified:
perl/embperl/trunk/Changes.pod
perl/embperl/trunk/Embperl/Form.pm
perl/embperl/trunk/Embperl/Form/Control.pm
perl/embperl/trunk/Embperl/Form/Control/radio.pm
perl/embperl/trunk/Embperl/Form/Control/transparent.pm
Modified: perl/embperl/trunk/Changes.pod
URL:
http://svn.apache.org/viewvc/perl/embperl/trunk/Changes.pod?rev=581932&r1=581931&r2=581932&view=diff
==============================================================================
--- perl/embperl/trunk/Changes.pod (original)
+++ perl/embperl/trunk/Changes.pod Thu Oct 4 07:43:55 2007
@@ -1,5 +1,9 @@
=pod
+=head1 2.3.1
+
+ - Support for internationalization in Emberl::Form
+
=head1 2.3.0 30. Sept. 2007
- Added support for Code ref in language message lookup hash.
Modified: perl/embperl/trunk/Embperl/Form.pm
URL:
http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form.pm?rev=581932&r1=581931&r2=581932&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form.pm (original)
+++ perl/embperl/trunk/Embperl/Form.pm Thu Oct 4 07:43:55 2007
@@ -496,7 +496,7 @@
{
my ($self, $req) = @_ ;
-warn "embperl::form::prepare_fdat [EMAIL PROTECTED]>{prepare_fdat}}" ;
+
foreach my $control (@{$self -> {prepare_fdat}})
{
$control -> prepare_fdat ($req) ;
@@ -687,6 +687,63 @@
}
+#------------------------------------------------------------------------------------------
+#
+# convert_label
+#
+# converts the label of a control to the text that should be outputed.
+# By default does return the text or name paramter of the control.
+# Can be overwritten to allow for example internationalization.
+#
+# in $ctrl Embperl::Form::Control object
+#
+
+sub convert_label
+ {
+ my ($self, $ctrl) = @_ ;
+
+ return $ctrl->{text} || $ctrl->{name} ;
+ }
+
+#------------------------------------------------------------------------------------------
+#
+# convert_values
+#
+# converts the values/options of a control to the text that should be
outputed.
+# By default does nothing.
+# Can be overwritten to allow for example internationalization.
+#
+# in $ctrl Embperl::Form::Control object
+# $values values of the control i.e. values that are submitted
+# $options options of the control i.e. text that should be displayed
+#
+
+sub convert_options
+ {
+ my ($self, $ctrl, $values, $options) = @_ ;
+
+ return $options ;
+ }
+
+#------------------------------------------------------------------------------------------
+#
+# convert_text
+#
+# converts the text of a controls like transparent to the text that should
be outputed.
+# By default does nothing.
+# Can be overwritten to allow for example internationalization.
+#
+# in $ctrl Embperl::Form::Control object
+# $values values of the control i.e. values that are submitted
+# $options options of the control i.e. text that should be displayed
+#
+
+sub convert_text
+ {
+ my ($self, $ctrl) = @_ ;
+
+ return $ctrl->{text} || $ctrl->{name} ;
+ }
1;
@@ -901,6 +958,55 @@
=head2 show
+=head2 convert_label
+
+Converts the label of a control to the text that should be outputed.
+By default does return the text or name paramter of the control.
+Can be overwritten to allow for example internationalization.
+
+=over
+
+=item $ctrl
+
+Embperl::Form::Control object
+
+=back
+
+=head2 convert_text
+
+Converts the text of a control to the text that should be outputed.
+By default does return the text or name paramter of the control.
+Can be overwritten to allow for example internationalization.
+
+=over
+
+=item $ctrl
+
+Embperl::Form::Control object
+
+=back
+
+=head2 convert_values
+
+Converts the values of a control to the text that should be outputed.
+By default does nothing.
+Can be overwritten to allow for example internationalization.
+
+=over
+
+=item $ctrl
+
+Embperl::Form::Control object
+
+=item $values
+
+values of the control i.e. values that are submitted
+
+=item $options
+
+options of the control i.e. text that should be displayed
+
+=back
=head1 AUTHOR
Modified: perl/embperl/trunk/Embperl/Form/Control.pm
URL:
http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control.pm?rev=581932&r1=581931&r2=581932&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control.pm Thu Oct 4 07:43:55 2007
@@ -197,7 +197,7 @@
# show - output the label
#]
-[$ sub show_label ($self, $req) $][+ $self->{text} || $self->{name}
+][$endsub$]
+[$ sub show_label ($self, $req) $][+ $self -> {showtext}?($self->{text} ||
$self->{name}):$self -> form -> convert_label ($self) +][$endsub$]
[# ---------------------------------------------------------------------------
#
@@ -359,7 +359,18 @@
=head3 text
Will be used as label for the control, if not given
-name is used as default
+'name' is used as default.
+
+Normaly the the name and text parameters are processed
+by the method C<convert_label> of the C<Embperl::Form>
+object. This method can be overwritten, to allow translation etc.
+
+If the parameter C<showtext> is given a true value, C<convert_label>
+is not called and the text is displayed as it is.
+
+=head3 showtext
+
+Display label without passing it through C<convert_label>. See C<text>.
=head2 labelnowrap
Modified: perl/embperl/trunk/Embperl/Form/Control/radio.pm
URL:
http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/radio.pm?rev=581932&r1=581931&r2=581932&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/radio.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/radio.pm Thu Oct 4 07:43:55 2007
@@ -77,6 +77,9 @@
my $set = !defined ($fdat{$name})?1:0 ;
my $nsprefix = $self -> form -> {jsnamespace} ;
+ $options = $self -> form -> convert_options ($self, $values, $options)
+ if (!$self -> {showoptions}) ;
+
my $val ;
my $i = 0 ;
Modified: perl/embperl/trunk/Embperl/Form/Control/transparent.pm
URL:
http://svn.apache.org/viewvc/perl/embperl/trunk/Embperl/Form/Control/transparent.pm?rev=581932&r1=581931&r2=581932&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/transparent.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/transparent.pm Thu Oct 4 07:43:55
2007
@@ -34,7 +34,7 @@
my $span = ($self->{width_percent}) ;
$]
-<td class="cBase cTransparentBox" colspan="[+ $span +]">[+ $self->{text}
+] </td>
+<td class="cBase cTransparentBox" colspan="[+ $span +]">[+ $self ->
{showtext}?($self->{text}):$self -> form -> convert_text ($self) +] </td>
[$endsub$]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]