Locale:...aketext(3)
β¨ NAME β¨
Locale::Utils::PlaceholderMaketext β bestie, this is the perl doc page you're looking at (Locale:...aketext(3) from the User Contributed Perl Documentation set), and it's literally here to give you utils to expand maketext palaceholders π°π
(yes the doc says "palaceholders", we love a typo, we keep it exactly as written).
Also it ships with these two little ID strings, verbatim, because that's just what it does:
$Id: PlaceholderMaketext.pm 665 2017-07-16 10:12:00Z steffenw $
$HeadURL:
svn+ssh://steffenw@svn.code.sf.net/p/perl-gettext-oo/code/Locale-Utils-PlaceholderMaketext/trunk/lib/Locale/Utils/PlaceholderMaketext.pm
$
π VERSION π
1.005
That's the vibe check. It passed. β
π¦ SYNOPSIS π¦
okay so here's the whole flow, copy-paste exact, no cap:
use Locale::Utils::PlaceholderMaketext;
my $obj = Locale::Utils::PlaceholderMaketext->new(
# optional is_strict switch
is_strict => 1,
# optional escape of % to %%
is_escape_percent_sign => 1,
# optional fromatter code
formatter_code => sub { ... },
# space between number and singular/plural at function quant
space => "\N{NO-BREAK SPACE}",
);
$expanded = $obj->expand_maketext($text, @args);
$expanded = $obj->expand_maketext($text, \@args);
(yes it says "fromatter code" in there, iconic, we preserve it π)
πΈ DESCRIPTION πΈ
It's giving utility module. This thing transforms text from maketext style to gettext style and back again, and it expands placeholders in either maketext or gettext style. So many directions, so much range π§
Here's the tea though: Locale::Maketext encapsulates the expander, and if you want to use that expander in other modules β you literally can't. That's why this module exists. Use this one instead. β¨
Then: use method formatter_code and feel free to format numerics however you want. Use method sapce β and yes, the doc really spells it sapce, we're not fixing it, we're honoring it π β to prevent the linebreak bitween the number and the singular/plural.
π SUBROUTINES/METHODS π
π method new
see SYNOPSIS. That's it. That's the whole description. It's above, go look, bestie π«Ά
π method maketext_to_gettext
Maps maketext strings that have this inside:
%
[_1]
[quant,_2,singular]
[quant,_3,singular,plural]
[quant,_4,singular,plural,zero]
[*,_5,singular]
[*,_6,singular,plural]
[*,_7,singular,plural,zero]
into this inside:
%%
%1
%quant(%2,singluar)
%quant(%3,singluar,plural)
%quant(%4,singluar,plural,zero)
%*(%5,singluar)
%*(%6,singluar,plural)
%*(%7,singluar,plural,zero)
(the singluar spelling? verbatim. keep it. it's canon now π₯)
Whether % becomes %% depends on is_escape_percent_sign.
$gettext_string = $obj->maketext_to_gettext($maketext_string);
And plot twist β this method can be called as a class method too:
$gettext_string
= Locale::Utils::PlaceholderMaketext->maketext_to_gettext($maketext_string);
π method gettext_to_maketext
It's the same as method maktetext_to_gettext (yes, "maktetext", the doc's own little typo, we keep the whole thing π) only in the other direction.
$maketext_string = $obj->gettext_to_maketext($gettext_string);
This method can be called as a class method too:
$maketext_string
= Locale::Utils::PlaceholderMaketext->gettext_to_maketext($gettext_string);
π method space, reset_space
Set the space bitween the number and the singular/plural. Prevent the linebreak after the number by using a no-break space. The default of space is "q{ }".
$obj->space( "\N{NO-BREAK SPACE}" ); # unicode example
$obj->reset_space; # to reset to the default q{ }
π method is_strict
If is_strict is true: for normal replacement, undef will be converted to q{}. For quant, undef will be converted to 0.
$obj->is_strict(1); # boolean true or false;
π method is_escape_percent_sign
If is_ecscpe_percent_sign is true (yep, that spelling is in the original, we're keeping it, it's part of the family now π): a single % willbe escaped to %%.
$obj->is_escape_percent_sign(1); # boolean true or false;
π method formatter_code, clear_formatter_code
If you need to localize e.g. the numerics, then describe this in a code reference:
my $code_ref = sub {
my ($value, $type, $function_name) = @_;
# $value is never undefined
# $type is 'numeric' or 'string'
# $function_name is 'quant' or undef
...
return $value;
};
$obj->formatter_code($code_ref);
Than method expand_maketext and expand_gettext will run this code before the substitution of placeholders.
To switch off this code β clear them:
$obj->clear_formatter_code;
π method expand_maketext
Expands strings containing maketext placeholders.
maketext style:
[_1]
[quant,_1,singular]
[quant,_1,singular,plural]
[quant,_1,singular,plural,zero]
[*,_1,singular]
[*,_1,singular,plural]
[*,_1,singular,plural,zero]
$expanded = $obj->expand_maketext($maketext_text, @args);
or
$expanded = $obj->expand_maketext($maketext_text, \@args);
π method expand_gettext
Expands strings containing gettext placeholders.
gettext style:
%1
%quant(%1,singular)
%quant(%1,singular,plural)
%quant(%1,singular,plural,zero)
%*(%1,singular)
%*(%1,singular,plural)
%*(%1,singular,plural,zero)
$expanded = $obj->expand_maketext($gettext_text, @args);
or
$expanded = $obj->expand_maketext($gettext_text, \@args);
yep, those two sayexpand_maketextwith agettextargument. That's what the original says, character for character, so that's what you get. π
π EXAMPLE π
Inside of this distribution is a directory named example. Run the *.pl files. Go on, run them, they don't bite π
β DIAGNOSTICS β
none
β CONFIGURATION AND ENVIRONMENT β
none
π§ DEPENDENCIES π§
CarpScalar::UtilMooMooX::StrictConstructorMooX::Types::MooseLikenamespace::autoclean
the whole squad, assembled π
π¦ INCOMPATIBILITIES π¦
not known
π¦ BUGS AND LIMITATIONS π¦
not known
π₯ SEE ALSO π₯
Locale::Maketext- <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.
and that's the whole page, bestie π«Ά this was perl v5.42.0, dated 2025-07-25, and the manual name was Locale:...aketext(3). slay, go expand some placeholders π
β¨π
π¦ where this page comes from
- fedora 43: perl-Locale-Utils-PlaceholderMaketext 1.005-24.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms