Locale:...sh::Loc(3)

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

🌸 Locale:...sh::Loc(3) 🌸

okay bestie, welcome to the User Contributed Perl Documentation corner of the internet πŸ’… this is Locale::TextDomain::OO::Plugin::Expand::BabelFish::Loc and she's here to give you extra BabelFish methods, all of them prefixed with loc_b. iykyk πŸ¦‹

$Id: $

$HeadURL: $


✨ VERSION ✨

1.027 β€” yes ma'am, that's the one πŸ‘‘


πŸ’– DESCRIPTION πŸ’–

so basically this module gives you translation with BabelFish writing 🌈

Use this plugin when you've got multiple plurals crammed into one phrase β€” otherwise, use Locale::TextDomain::OO::Plugin::Expand::Gettext::Loc, because honestly that writing style is way easier for a translation office to read. Gettext writing has no or constructs and less cryptic chars inside, so the translation office doesn't need programmer experience. it's giving accessible, it's giving considerate, periodt πŸŽ€


🫢 SYNOPSIS 🫢

my $loc = Locale::Text::TextDomain::OO->new(
    plugins => [ qw (
        Expand::BabelFish::Loc
        ...
    )],
    ...
);

optional type formatting or grammar stuff? peek at Locale::Utils::PlaceholderBabelFish for the possible methods πŸ‘€

$loc->expand_babel_fish_loc->modifier_code($code_ref);

πŸ‘‘ SUBROUTINES/METHODS πŸ‘‘

🧚 method expand_babel_fish_loc

Returns the Locale::Utils::PlaceholderBabelFish object, so you can go in and set some options. slay ✨

my $expander_object = $self->expand_babel_fish_loc;

e.g.

$self->expand_babel_fish_loc->plural_code(
    $loc->plural_code,
);

$self->expand_babel_fish_loc->modifier_code(
    sub {
        my ( $value, $attribute ) = @_;
        if ( $attribute eq 'numf' ) {
            # modify that numeric $value
            # e.g. change 1234.56 to 1.234,56 or 1,234.56
            ...
        }
        elsif ( $attribute eq 'accusative' ) {
            # modify the string with that grammar rule
            # e.g. needed for East-European languages
            # write grammar rules only on msgstr/msgstr_plural[n]
            # and not on msgid
            ...
        }
        ...
        return $value;
    },
);

πŸ’œ translation methods

so how do you build the method name? take loc_b and append it with "p" πŸ’«

 .------------------------------------------------------------------------.
 | Snippet | Description                                                  |
 |---------+--------------------------------------------------------------|
 | p       | Context is the first parameter.                              |
 '------------------------------------------------------------------------'

πŸ¦‹ method loc_b

translate only, nothing fancy

print $loc->loc_b(
    'Hello World!',
);

πŸ¦‹ method loc_bp

context, babes β€” it's the first parameter's whole moment

print $loc->loc_bp(
    'time', # Context
    'to',
);

print $loc->loc_bp(
    'destination', # Context
    'to',
);

🌸 Methods to mark the translation for extraction only

how do you build these method names? take Nloc_b and append it with "p" 🌷

 .------------------------------------------------------------------------.
 | Snippet | Description                                                  |
 |---------+-------------------------------------------------------------- |
 | p       | Context is the first parameter.                              |
 '------------------------------------------------------------------------'

⭐ methods Nloc_b, Nloc_bp

the extractor is out here looking for "loc_b('..." and has zero problem with "$loc->Nloc_b('..." β€” no cap πŸ’€

that's literally the whole idea of the N-Methods, bestie

$loc->Nloc_b('...');
$loc->Nloc_bp('...', '...');

πŸ“ EXAMPLE πŸ“

Inside of this distribution is a directory named example. Run this *.pl files. go off, run them πŸ‘


πŸ’€ DIAGNOSTICS πŸ’€

confess


🧸 CONFIGURATION AND ENVIRONMENT 🧸

none β€” nothing to configure, she's low maintenance


🌈 DEPENDENCIES 🌈

  • Locale::Utils::PlaceholderBabelFish
  • Moo::Role

πŸ™ˆ INCOMPATIBILITIES πŸ™ˆ

not known β€” no drama found (yet)


πŸŽ€ BUGS AND LIMITATIONS πŸŽ€

none β€” flawless behaviour, as she deserves πŸ’…


πŸ’– SEE ALSO πŸ’–

  • Locale::TextDoamin::OO
  • Locale::TextDomain::OO::Plugin::Expand::Gettext::Loc

πŸ‘‘ AUTHOR πŸ‘‘

Steffen Winkler


Copyright (c) 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, brought to you by the fine folks at Locale:...sh::Loc(3) β€” go translate something iconic πŸ’–βœ¨

πŸ“¦ where this page comes from