1Locale::Utils::PlaceholUdseerrNaCmoendt(r3i)buted Perl DLooccuamleen:t:aUttiiolns::PlaceholderNamed(3)
2
3
4

NAME

6       Locale::Utils::PlaceholderNamed - Utils to expand named placeholders
7
8       $Id: PlaceholderNamed.pm 667 2017-07-16 10:46:35Z steffenw $
9
10       $HeadURL:
11       svn+ssh://steffenw@svn.code.sf.net/p/perl-gettext-oo/code/Locale-Utils-PlaceholderNamed/trunk/lib/Locale/Utils/PlaceholderNamed.pm
12       $
13

VERSION

15       1.004
16

SYNOPSIS

18           use Locale::Utils::PlaceholderNamed;
19
20           my $obj = Locale::Utils::PlaceholderNamed->new(
21               # optional is_strict switch
22               is_strict => 1,
23               # optional modifier code
24               modifier_code => sub {
25                   my ( $value, $attribute ) = @_;
26                   return
27                       $attribute eq '%.3f'
28                       ? sprintf($attribute, $value)
29                       : $attribute eq 'accusative'
30                       ? accusative($value)
31                       : $value;
32               },
33           );
34
35           $expanded = $obj->expand_named($text, %args);
36           $expanded = $obj->expand_named($text, \%args);
37

DESCRIPTION

39       Utils to expand named placeholders.
40

SUBROUTINES/METHODS

42   method new
43       see SYNOPSIS
44
45   method is_strict
46       If is_strict is false: undef will be converted to q{}.  If is_strict is
47       true: no replacement.
48
49           $obj->is_strict(1); # boolean true or false;
50
51   method modifier_code, clear_modifier_code
52       The modifier code handles named attributes to modify the given
53       placeholder value.
54
55       If the placeholder name is "{foo:bar}" then foo is the placeholder name
56       and bar the attribute name.  Space in front of the attribute name is
57       allowed, e.g. "{foo :bar}".
58
59           my $code_ref = sub {
60               my ( $value, $attribute ) = @_;
61               return
62                   $attribute eq 'num.03'
63                   ? sprintf('%.03f, $value)
64                   : $attribute eq 'accusative'
65                   ? accusative($value)
66                   : $value;
67           };
68           $obj->modifier_code($code_ref);
69
70       To switch off this code - clear them.
71
72           $obj->clear_modifier_code;
73
74   method expand_named
75       Expands strings containing named placeholders like "{name}".
76
77           $text = 'foo {name} baz';
78           %args = (
79               name => 'bar',
80           );
81
82           $expanded = $obj->expand_named($text, %args);
83
84       or
85
86           $expanded = $obj->expand_text($text, \%args);
87

JAVASCRIPT

89       Inside of this distribution is a directory named javascript.  For more
90       information see: Locale::TextDomain::OO::JavaScript
91
92       This script depends on <http://jquery.com/>.
93

EXAMPLE

95       Inside of this distribution is a directory named example.  Run the *.pl
96       files.
97

DIAGNOSTICS

99       none
100

CONFIGURATION AND ENVIRONMENT

102       none
103

DEPENDENCIES

105       Carp
106
107       Moo
108
109       MooX::StrictConstructor
110
111       MooX::Types::MooseLike
112
113       namespace::autoclean
114

INCOMPATIBILITIES

116       not known
117

BUGS AND LIMITATIONS

119       not known
120

SEE ALSO

122       <http://en.wikipedia.org/wiki/Gettext>
123
124       Locale::TextDomain
125

AUTHOR

127       Steffen Winkler
128
130       Copyright (c) 2011 - 2017, Steffen Winkler "<steffenw at cpan.org>".
131       All rights reserved.
132
133       This module is free software; you can redistribute it and/or modify it
134       under the same terms as Perl itself.
135
136
137
138perl v5.34.0                      2021-07-22Locale::Utils::PlaceholderNamed(3)
Impressum