Locale:...le::File(3)
π Locale::TextDomain::OO::Lexicon::Role::File(3) π
okay bestie so this is a page from the User Contributed Perl Documentation, and the module we're stanning today is Locale::TextDomain::OO::Lexicon::Role::File π it's a helper role that adds a lexicon from a file, and honestly? iconic behaviour.
$Id: File.pm 722 2018-12-21 12:24:14Z steffenw $
$HeadURL: svn+ssh://steffenw@svn.code.sf.net/p/perl-gettext-oo/code/module/trunk/lib/Locale/TextDomain/OO/Lexicon/Role/File.pm $
β¨ VERSION β¨
1.034 β she's been around, she's thriving π
πΈ DESCRIPTION πΈ
This module provides methods to inplmement lexicon from file easy. yes, that's what the original says, and no, we're not fixing the typo, we're preserving it, that's the whole assignment π«Ά basically it gives you the methods to make a lexicon-from-file setup super easy.
π¦ SYNOPSIS π¦
with qw(
Locale::TextDomain::OO::Lexicon::Role::File
);
that's it, that's the vibe check. you just with it. π§
π SUBROUTINES/METHODS π
π attribute decode_code
Allows to implement your own way of decode messages. Add a code ref in constructor.
decode_code => sub {
my ($charset, $text) = @_;
defined $text
or return $text;
return decode( $charset, $text );
},
so like, you bring your own decoding logic and drop it in the constructor. main character energy, your rules π
π method lexicon_ref
$self->lexicon_ref({
# required
search_dirs => [ qw( ./my_dir ./my_other_dir ) ],
# optional
gettext_to_maketext => $boolean,
# optional
decode => $boolean,
# required
data => [
# e.g. de.mo, en.mo read from:
# search_dir/de.mo
# search_dir/en.mo
'*::' => '*.mo',
# e.g. de.mo en.mo read from:
# search_dir/subdir/de/LC_MESSAGES/domain.mo
# search_dir/subdir/en/LC_MESSAGES/domain.mo
'*:LC_MESSAGES:domain' => 'subdir/*/LC_MESSAGES/domain.mo',
# Merge a region lexicon:
# Take the header and messages of the "de::" lexicon,
# overwrite the header and messages of the "de-at::" lexicon
# and store that as "de-at::" lexicon with all messages now.
merge_lexicon => 'de::', 'de-at::' => 'de-at::',
# Copy a lexicon into another domain and/or category:
copy_lexicon => 'i-default::' => 'i-default:LC_MESSAGES:domain',
# Move a lexicon into another domain and/or category:
move_lexicon => 'i-default::' => 'i-default:LC_MESSAGES:domain',
# Delete a lexicon:
delete_lexicon => 'i-default::',
],
});
so the tea here βοΈ:
search_dirsis required β that's your array of dirs to look in.gettext_to_maketextis optional β takes$boolean.decodeis optional β also takes$boolean.datais required β this is the list where the actual magic happens:'*::' => '*.mo'grabs stuff likede.mo,en.mofromsearch_dir/de.moandsearch_dir/en.mo.'*:LC_MESSAGES:domain' => 'subdir/*/LC_MESSAGES/domain.mo'grabs e.g.de.moanden.mofromsearch_dir/subdir/de/LC_MESSAGES/domain.moandsearch_dir/subdir/en/LC_MESSAGES/domain.mo.merge_lexicon => 'de::', 'de-at::' => 'de-at::'merges a region lexicon β takes the header and messages of thede::lexicon, overwrites the header and messages of thede-at::lexicon, and stores that as thede-at::lexicon with all messages now. slay.copy_lexicon => 'i-default::' => 'i-default:LC_MESSAGES:domain'copies a lexicon into another domain and/or category.move_lexicon => 'i-default::' => 'i-default:LC_MESSAGES:domain'moves a lexicon into another domain and/or category.delete_lexicon => 'i-default::'deletes a lexicon. gone. π
π method logger
Set the logger and get back them. fr fr, that's the deal β set it, and it hands it right back to you.
$lexicon_hash->logger(
sub {
my ($message, $arg_ref) = @_;
my $type = $arg_ref->{type};
$log->$type($message);
return;
},
);
$logger = $lexicon_hash->logger;
and $arg_ref contains:
object => $lexicon_hash, # the object itself
type => 'debug',
event => 'lexicon,load', # The logger will be copied to
# Locale::TextDomain::OO::Singleton::Lexicon
# so more events are possible.
so object is the object itself, type is like 'debug', and event here is 'lexicon,load' β and lowkey important detail: the logger will be copied to Locale::TextDomain::OO::Singleton::Lexicon, so more events are possible. iykyk π
π EXAMPLE π
Inside of this distribution is a directory named example. Run this *.pl files.
π₯ DIAGNOSTICS π₯
confess
π CONFIGURATION AND ENVIRONMENT π
none. no config, no env vars, nothing to stress about, we love a low-maintenance queen.
π DEPENDENCIES π
CarpEncodeEnglishLocale::TextDomain::OO::Singleton::LexiconLocale::TextDomain::OO::Util::ExtractHeaderLocale::TextDomain::OO::Util::JoinSplitLexiconKeysMoo::RoleMooX::Types::MooseLike::BasePath::Tinynamespace::autocleanLocale::TextDomain::OO::Lexicon::Role::GettextToMaketextLocale::TextDomain::OO::Role::Logger
look at that roster, it's giving squad goals π«Ά
π INCOMPATIBILITIES π
not known
π BUGS AND LIMITATIONS π
none. no bugs, no limitations, she's perfect, periodt.
β SEE ALSO β
Locale::TextDoamin::OO
(yes, spelled exactly like that β we do not touch the spelling, that's the rule π )
π AUTHOR π
Steffen Winkler
π LICENSE AND COPYRIGHT π
Copyright (c) 2013 - 2018, 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 a wrap bestie πΈ this page came to you via perl v5.42.0, dated 2025-07-25, under the manual name Locale:...le::File(3) β go forth and lexicon from file responsibly π
β¨
π¦ where this page comes from
- fedora 43: perl-Locale-TextDomain-OO 1.036-19.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