Locale:...derNamed(3)

πŸ“¦
version 1.004 Β· 2 versions
, in fedora 43

πŸ’– Locale::Utils::PlaceholderNamed πŸ’–

okay bestie, so this page lives in the User Contributed Perl Documentation, manual section 3 (that's the library-functions section, iykyk), and the page title is Locale:...derNamed(3). Yes that's the truncated name, it's giving "the filesystem had a limit and we respect it". Let's go 🫢

✨ NAME ✨

Locale::Utils::PlaceholderNamed β€” Utils to expand named placeholders πŸŽ€

$Id: PlaceholderNamed.pm 667 2017-07-16 10:46:35Z steffenw $
$HeadURL:
svn:ssh://steffenw@svn.code.sf.net/p/perl-gettext-oo/code/Locale-Utils-PlaceholderNamed/trunk/lib/Locale/Utils/PlaceholderNamed.pm
$
wait, careful with that second one β€” it's exactly svn+ssh://steffenw@svn.code.sf.net/p/perl-gettext-oo/code/Locale-Utils-PlaceholderNamed/trunk/lib/Locale/Utils/PlaceholderNamed.pm in the original, and the lines wrap weirdly around the $HeadURL: and the closing $. Copy it, don't retype it from memory πŸ’€

🌸 VERSION 🌸

1.004 β€” that's the one, no cap ⭐


πŸ¦‹ 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);

look at her, she's so tidy 😭✨


🌈 DESCRIPTION 🌈

Utils to expand named placeholders. That's the whole vibe, bestie. Named placeholders get expanded. πŸ’…


πŸ‘‘ SUBROUTINES/METHODS πŸ‘‘

method new

see SYNOPSIS β€” literally, go look up, it's right there πŸ™ˆ

method is_strict

Okay so this is the strictness switch and it matters:

  • if is_strict is false, undef gets converted to q{} (empty string, babes)
  • if is_strict is true, there's no replacement at all
$obj->is_strict(1); # boolean true or false;

yes the comment in the original is just like that, and yes you pass it a boolean, true or false, iconic behavior πŸ’–

method modifier_code, clear_modifier_code

The modifier code handles named attributes to modify the given placeholder value. It's the glow-up department for your placeholders ✨

So here's the tea: if the placeholder name is "{foo:bar}", then foo is the placeholder name and bar is the attribute name. And a space in front of the attribute name is allowed too, like "{foo :bar}". Look at her being flexible πŸŽ€

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);

(ngl that '%.03f up there is missing its closing quote β€” that's literally what the original page says, so I'm keeping it, don't @ me πŸ™ˆ)

Wanna switch off this code? Just clear it, bestie:

$obj->clear_modifier_code;

method expand_named

Expands strings containing named placeholders like "{name}". The moment we've all been waiting for πŸ’…

$text = 'foo {name} baz';
%args = (
    name => 'bar',
);

$expanded = $obj->expand_named($text, %args);

or

$expanded = $obj->expand_text($text, \%args);
yes, the "or" branch calls expand_text β€” that's what the page says, verbatim, character for character. Not a typo I introduced, I promise 🫢

🧚 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/>. (yes, jquery, she's vintage, she's a classic, she ate πŸ”₯)


πŸ“ EXAMPLE πŸ“

Inside of this distribution is a directory named example. Run the *.pl files. Go on, run them, they don't bite πŸ’œ


πŸ’€ DIAGNOSTICS πŸ’€

none

like, literally none. no drama. we love a low-maintenance module 😌


⭐ CONFIGURATION AND ENVIRONMENT ⭐

none

nothing to configure, nothing in your env, just vibes ✨


πŸŽ€ DEPENDENCIES πŸŽ€

She does not stand alone, bestie, she has a whole friend group:

  • Carp
  • Moo
  • MooX::StrictConstructor
  • MooX::Types::MooseLike
  • namespace::autoclean

πŸ™ˆ INCOMPATIBILITIES πŸ™ˆ

not known


🌸 BUGS AND LIMITATIONS 🌸

not known

(no known bugs, main character energy fr fr πŸ‘‘)


πŸ”₯ SEE ALSO πŸ”₯


πŸ’– AUTHOR πŸ’–

Steffen Winkler


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.


and that's the whole page, bestie 🫢 perl v5.42.0 blessed us with this one on 2025-07-25, and it's still serving Locale:...derNamed(3) in the User Contributed Perl Documentation like the absolute icon she is πŸ’…βœ¨ mwah, go expand some placeholders πŸŽ€

πŸ“¦ where this page comes from