Locale-TextDomain-OO

 view release on metacpan or  search on metacpan

t/22_loc_mo_style_gettext.t  view on Meta::CPAN

#!perl -T

use strict;
use warnings;

use Test::More tests => 19;
use Test::NoWarnings;
use Test::Differences;

BEGIN {
    require_ok('Locale::TextDomain::OO');
    require_ok('Locale::TextDomain::OO::Lexicon::File::MO');
}

Locale::TextDomain::OO::Lexicon::File::MO
    ->new(
        logger => sub { note shift },
    )
    ->lexicon_ref({
        search_dirs         => [ './t/LocaleData' ],
        gettext_to_maketext => 1,
        data                => [
            '*:LC_MESSAGES:test_maketext_style_gettext' => '*/LC_MESSAGES/test_maketext_style_gettext.mo',
        ],
    });

my $loc = Locale::TextDomain::OO->new(
    language => 'de',
    category => 'LC_MESSAGES',
    domain   => 'test_maketext_style_gettext',
    plugins  => [ qw( Expand::Maketext::Loc ) ],
    logger   => sub { note shift },
);
is
    $loc->loc(
        'This is a text.',
    ),
    'Das ist ein Text.',
    'loc';
is
    $loc->loc(
        '§ book',
    ),
    '§ Buch',
    'loc, umlaut';
is
    $loc->loc(
        '[_1] is programming [_2].',
        'Steffen',
        'Perl',
    ),
    'Steffen programmiert Perl.',
    'loc, placeholder';
is
    $loc->loc(
        '[_1] is programming [_2].',
        'Steffen',
    ),
    'Steffen programmiert .',
    'loc, missing placeholder';
is
    $loc->loc(
        '[quant,_1,shelf,shelves]',
        1,
    ),
    '1 Regal',
    'loc, quant 1';
is



( run in 2.381 seconds using v1.01-cache-2.11-cpan-75ffa21a3d4 )