diff --git a/lib/WebGUI/Definition/Role/Object.pm b/lib/WebGUI/Definition/Role/Object.pm index cd465cbf3..2343f5d63 100644 --- a/lib/WebGUI/Definition/Role/Object.pm +++ b/lib/WebGUI/Definition/Role/Object.pm @@ -126,6 +126,20 @@ calling subroutines for values. Each subroutine is invoked as a method of the object, and is passed the entire set of form properties and the name of the property. +i18n is allowed in the label, subtext and hoverHelp options, and is specified by passing +an array reference. + + label => [ 'key', 'namespace' ], + +If the array reference has more than two elements, getFormProperties will pass the retrieved +i18n key to sprintf, with the extra elements as arguments. + + label => [ 'key', 'namespace', 'extra' ], + +becomes + + label => sprintf($i18n->get('label', 'namespace'), 'extra'), + =head3 $name The name of the property to return. @@ -139,7 +153,12 @@ sub getFormProperties { PROPERTY: while (my ($property_name, $property_value) = each %{ $form }) { next PROPERTY unless ref $property_value; if (($property_name eq 'label' || $property_name eq 'hoverHelp' || $property_name eq 'subtext') and ref $property_value eq 'ARRAY') { - $form->{$property_name} = WebGUI::International->new($self->session)->get(@{$property_value}); + my ($label, $namespace, @arguments) = @{ $property_value }; + my $text = WebGUI::International->new($self->session)->get($label, $namespace); + if (@arguments) { + $text = sprintf $text, @arguments; + } + $form->{$property_name} = $text; } elsif (ref $property_value eq 'CODE') { $form->{$property_name} = $self->$property_value($property, $property_name); diff --git a/lib/WebGUI/i18n/English/WebGUI.pm b/lib/WebGUI/i18n/English/WebGUI.pm index 9dff73b0e..246567ba3 100644 --- a/lib/WebGUI/i18n/English/WebGUI.pm +++ b/lib/WebGUI/i18n/English/WebGUI.pm @@ -3587,7 +3587,13 @@ LongTruncOk=1

'webgui' => { message => q|WebGUI|, lastUpdated => 1141963573, - context => q|Test key for International macro test. DO NOT TRANSLATE|, + context => q|Test key for International macro test. DO NOT TRANSLATE OR DELETE|, + }, + + 'webgui help %s' => { + message => q|webgui help %s|, + lastUpdated => 1266003122, + context => q|Test key for Definition::Role::Object. DO NOT TRANSLATE OR DELETE|, }, 'pages' => { diff --git a/t/Definition.t b/t/Definition.t index 2e592a0b0..b697a1d29 100644 --- a/t/Definition.t +++ b/t/Definition.t @@ -105,6 +105,7 @@ my $called_getProperties; aspect 'aspect1' => 'aspect1 value'; property 'property1' => ( label => ['webgui', 'WebGUI'], + hoverHelp => ['webgui help %s', 'WebGUI', 'extra'], options => \&property1_options, named_url => \&named_url, ); @@ -130,6 +131,7 @@ my $called_getProperties; $object->getFormProperties('property1'), { label => 'WebGUI', + hoverHelp => 'webgui help extra', options => { one => 1, two => 2, three => 3 }, named_url => 'property1', },