-
-
24 Feb 2017 13:44:01 UTC
- Distribution: Locale-Utils-PlaceholderNamed
- Module version: 1.002
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues
- Testers (752 / 0 / 0)
- Kwalitee
Bus factor: 1- 95.24% Coverage
- License: perl_5
- Perl: v5.6.0
- Activity
24 month- Tools
- Download (8.52KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 1 contributors- Steffen Winkler <steffenw at cpan.org>
- Dependencies
- Carp
- Moo
- MooX::StrictConstructor
- MooX::Types::MooseLike
- namespace::autoclean
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
- NAME
- VERSION
- SYNOPSIS
- DESCRIPTION
- SUBROUTINES/METHODS
- JAVASCRIPT
- EXAMPLE
- DIAGNOSTICS
- CONFIGURATION AND ENVIRONMENT
- DEPENDENCIES
- INCOMPATIBILITIES
- BUGS AND LIMITATIONS
- SEE ALSO
- AUTHOR
- LICENSE AND COPYRIGHT
NAME
Locale::Utils::PlaceholderNamed - Utils to expand named placeholders
$Id: PlaceholderNamed.pm 587 2015-04-16 05:58:10Z steffenw $
$HeadURL: svn+ssh://steffenw@svn.code.sf.net/p/perl-gettext-oo/code/Locale-Utils-PlaceholderNamed/trunk/lib/Locale/Utils/PlaceholderNamed.pm $
VERSION
1.002
SYNOPSIS
use Locale::Utils::PlaceholderNamed; my $obj = Locale::Utils::PlaceholderNamed->new( # optional is_strict switch is_strict => 1, # optional modifier code modifier_code => sub { my ( $value, $attribute ) = @_; return $attribute eq '%.3f' ? sprintf($attribute, $value) : $attribute eq 'accusative' ? accusative($value) : $value; }, ); $expanded = $obj->expand_named($text, %args); $expanded = $obj->expand_named($text, \%args);
DESCRIPTION
Utils to expand named placeholders.
SUBROUTINES/METHODS
method new
see SYNOPSIS
method is_strict
If is_strict is false: undef will be converted to q{}. If is_strict is true: no replacement.
$obj->is_strict(1); # boolean true or false;
method modifier_code, clear_modifier_code
The modifier code handles named attributes to modify the given placeholder value.
If the placeholder name is
{foo:bar}
then foo is the placeholder name and bar the attribute name. Space in front of the attribute name is allowed, e.g.{foo :bar}
.my $code_ref = sub { my ( $value, $attribute ) = @_; return $attribute eq 'num.03' ? sprintf('%.03f, $value) : $attribute eq 'accusative' ? accusative($value) : $value; }; $obj->modifier_code($code_ref);
To switch off this code - clear them.
$obj->clear_modifier_code;
method expand_named
Expands strings containing named placeholders like
{name}
.$text = 'foo {name} baz'; %args = ( name => 'bar', ); $expanded = $obj->expand_named($text, %args);
or
$expanded = $obj->expand_text($text, \%args);
JAVASCRIPT
Inside of this distribution is a directory named javascript. For more information see: Locale::TextDomain::OO::JavaScript
This script depends on http://jquery.com/.
EXAMPLE
Inside of this distribution is a directory named example. Run the *.pl files.
DIAGNOSTICS
none
CONFIGURATION AND ENVIRONMENT
none
DEPENDENCIES
INCOMPATIBILITIES
not known
BUGS AND LIMITATIONS
not known
SEE ALSO
http://en.wikipedia.org/wiki/Gettext
AUTHOR
Steffen Winkler
LICENSE AND COPYRIGHT
Copyright (c) 2011 - 2017, Steffen Winkler
<steffenw at cpan.org>
. All rights reserved.This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install Locale::Utils::PlaceholderNamed, copy and paste the appropriate command in to your terminal.
cpanm Locale::Utils::PlaceholderNamed
perl -MCPAN -e shell install Locale::Utils::PlaceholderNamed
For more information on module installation, please visit the detailed CPAN module installation guide.