| Data-Localize documentation | Contained in the Data-Localize distribution. |
Data::Localize::Format::NamedArgs - Process Lexicons With Named Args (As Opposed To Positional Args)
# "Hello {{name}}" -> "Hello, John"
$loc->localize( "lexicon_key", { name => "John" } );
| Data-Localize documentation | Contained in the Data-Localize distribution. |
package Data::Localize::Format::NamedArgs; use Any::Moose; extends 'Data::Localize::Format'; no Any::Moose; sub format { my ($self, $lang, $value, $args) = @_; return $value unless ref $args eq 'HASH'; $value =~ s/{{([^}]+)}}/ $args->{ $1 } || '' /ex; return $value; } __PACKAGE__->meta->make_immutable(); 1; __END__