Locale:...File::MO(3)

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

πŸ’– Locale::TextDomain::OO::Lexicon::File::MO β€” bestie edition πŸ’–

okay so this is a page from the User Contributed Perl Documentation, and it's all about Locale::TextDomain::OO::Lexicon::File::MO. yep. that whole thing. say it three times fast, i dare you 🫢


🌸 NAME 🌸

Locale::TextDomain::OO::Lexicon::File::MO β€” gettext mo file as lexicon. that's the whole job, she's a reader, she's a converter, she's iconic ✨

and because the ancients loved metadata, here's the version-control lore, verbatim, do not touch:

$Id: MO.pm 698 2017-09-28 05:21:05Z steffenw $

$HeadURL:
svn:ssh://steffenw@svn.code.sf.net/p/perl-gettext-oo/code/module/trunk/lib/Locale/TextDomain/OO/Lexicon/File/MO.pm
ok bestie, tiny correction, the real line is svn+ssh://steffenw@svn.code.sf.net/p/perl-gettext-oo/code/module/trunk/lib/Locale/TextDomain/OO/Lexicon/File/MO.pm β€” no cap, that's the URL. πŸ’…

✨ VERSION ✨

1.031 β€” that's the vibe check result, we pass βœ…


πŸ¦‹ DESCRIPTION πŸ¦‹

This module reads a gettext mo file into the lexicon. that's it. that's the whole personality. it takes the .mo and goes nom nom nom and now you have lexicon ✨ lowkey magical.


πŸŽ€ SYNOPSIS πŸŽ€

here's the whole flex, copy-paste ready, character for character, i would never edit your code bestie:

use Locale::TextDomain::OO::Lexicon::File::MO;
use Log::Any qw($log);

$logger = Locale::TextDomain::OO::Lexicon::File::MO
    ->new(
        # all parameters are optional
        decode_code => sub {
            my ($charset, $text) = @_;
            defined $text
                or return $text;
            return decode( $charset, $text );
        },
        # optional
        logger => sub {
            my ($message, $arg_ref) = @_;
            my $type = $arg_ref->{type}; # debug
            $log->$type($message);
            return;
        },
    )
    ->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::',
        ],
    })
    ->logger;

like… the merge/copy/move/delete block? that's the main character energy right there πŸ‘‘


πŸ’… SUBROUTINES/METHODS πŸ’…

🌟 method new

see SYNOPSIS. (she's mysterious. she's giving less is more. iykyk.)

🌟 method lexicon_ref

See SYNOPSIS. same energy fr fr.

🌟 method read_messages

Called from Locale::TextDomain::OO::Lexicon::Role::File to run the mo file specific code. this is the one that actually does the reading bestie πŸ“

$messages_ref = $self->read_messages($filename);

🌟 method logger

Set the logger and get back them. yes, "them" β€” the method is both the setter and the getter, versatile queen πŸŽ€

$lexicon_file_mo->logger(
    sub {
        my ($message, $arg_ref) = @_;
        my $type = $arg_ref->{type};
        $log->$type($message);
        return;
    },
);
$logger = $lexicon_hash->logger;

$arg_ref contains:

object => $lexicon_file_mo, # the object itself
type   => 'debug',
event  => 'lexicon,load', # The logger will be copied to
                          # Locale::TextDomain::OO::Singleton::Lexicon
                          # so more events are possible.
heads up bestie: that event comment means the logger gets copied over to Locale::TextDomain::OO::Singleton::Lexicon, so more events are possible. not me guessing, that's literally what it says πŸ’œ

🌈 EXAMPLE 🌈

Inside of this distribution is a directory named example. Run this *.pl files. go on, run them, they don't bite πŸ¦‹


πŸ’€ DIAGNOSTICS πŸ’€

none. silence. no drama. we love a chill module 😌


🧚 CONFIGURATION AND ENVIRONMENT 🧚

none. zero config, zero env vars, she simply exists ✨


πŸ‘‘ DEPENDENCIES πŸ‘‘

okay so she doesn't come alone, she brings her friends:

  • Locale::MO::File
  • Moo
  • MooX::StrictConstructor
  • Locale::TextDomain::OO::Lexicon::Role::File

squad goals fr fr 🫢


πŸ™ˆ INCOMPATIBILITIES πŸ™ˆ

not known. (translation: nobody has caught her beefing with anyone yet. keep it that way.)


😭 BUGS AND LIMITATIONS 😭

none. no bugs, no limitations, she's literally perfect, and i'm not being biased i'm just reading the page πŸ’…


⭐ SEE ALSO ⭐

  • Locale::TextDoamin::OO
bestie don't panic β€” yes it's spelled TextDoamin and i am keeping it exactly as written, character for character, no fixing, that's the rule πŸŽ€

πŸ’– AUTHOR πŸ’–

Steffen Winkler. legend behavior. thank you for your service 🫑


Copyright (c) 2013 - 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, no details skipped, every flag and every path intact πŸ’œ

cute lil sign-off: this is Locale:...File::MO(3) from perl v5.42.0, dated 2025-07-25. slay, goodbye, go read your .mo files πŸŽ€βœ¨

πŸ“¦ where this page comes from