Locale:...File::PO(3)

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

πŸ’– NAME πŸ’–

okay so bestie, welcome to Locale::TextDomain::OO::Lexicon::File::PO β€” it's literally the module that reads a gettext po file into the lexicon. That's the whole gig. It's giving translator-energy, no cap.

This is part of the User Contributed Perl Documentation, and yes she has ✨commit metadata✨:

$Id: PO.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/PO.pm
$

🌸 VERSION 🌸

1.031 β€” that's the version, periodt.


πŸ¦‹ DESCRIPTION πŸ¦‹

This module reads a gettext po file into the lexicon. That's it, that's the vibe. po file in, lexicon out πŸ’…


✨ SYNOPSIS ✨

the way that this is the whole flex, honestly:

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

$logger = Locale::TextDomain::OO::Lexicon::File::PO
    ->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.po, en.po read from:
            # search_dir/de.po
            # search_dir/en.po
            '*::' => '*.po',

            # e.g. de.po en.po read from:
            # search_dir/subdir/de/LC_MESSAGES/domain.po
            # search_dir/subdir/en/LC_MESSAGES/domain.po
            '*:LC_MESSAGES:domain' => 'subdir/*/LC_MESSAGES/domain.po',

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

πŸŽ€ SUBROUTINES/METHODS πŸŽ€

πŸ’œ method new

see SYNOPSIS πŸ‘† (she's lowkey just pointing up, iconic)

πŸ’œ method lexicon_ref

See SYNOPSIS. fr fr, go look.

πŸ’œ method read_messages

Called from Locale::TextDomain::OO::Lexicon::Role::File to run the po file specific code. Like, that's her job, she runs the po-specific bits 🫢

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

πŸ’œ method logger

Set the logger and get back them 😌

$lexicon_file_po->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_po, # the object itself
type   => 'debug',
event  => 'lexicon,load', # The logger will be copied to
                          # Locale::TextDomain::OO::Singleton::Lexicon
                          # so more events are possible.

🌈 EXAMPLE 🌈

Inside of this distribution is a directory named example. Run this *.pl files. bestie just go run them, they're right there πŸ’…


πŸ’€ DIAGNOSTICS πŸ’€

none. literally none. nothing to report, we're chill.


🧚 CONFIGURATION AND ENVIRONMENT 🧚

none. no env vars, no config, no drama πŸ™ˆ


πŸ“ DEPENDENCIES πŸ“

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

😭 INCOMPATIBILITIES 😭

not known. (as far as we know she plays nice with everyone πŸ’–)


πŸ’… BUGS AND LIMITATIONS πŸ’…

none. zero. the bug count is giving zero, periodt.


πŸ‘‘ SEE ALSO πŸ‘‘

Locale::TextDoamin::OO

(yes, that's spelled exactly like that in the source β€” copying it character for character because that is THE RULE ✨)

🌸 AUTHOR 🌸

Steffen Winkler β€” the main character who wrote this πŸ‘‘


Copyright (c) 2014 - 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.


okay that's the whole page bestie, ily, go read some po files πŸ’–βœ¨

this was served up by perl v5.42.0, dated 2025-07-25, from the Locale:...File::PO(3) page β€” mwah 🫢

πŸ“¦ where this page comes from