| 1 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||
| 3 | # Module: Term::CLI::L10N | ||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||
| 5 | # Author: Steven Bakker (SBAKKER), <cpanman@monkey-mind.net> | ||||||||||||||||||||||||||||||||||
| 6 | # Created: 27/02/18 | ||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||
| 8 | # Copyright (c) 2018-2022 Steven Bakker; All rights reserved. | ||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||
| 10 | # This module is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||
| 11 | # it under the same terms as Perl itself. See "perldoc perlartistic." | ||||||||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||||||||
| 13 | # This software is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||||||||
| 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||||||||
| 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||||||||||||||||||||||||||
| 16 | # | ||||||||||||||||||||||||||||||||||
| 17 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||
| 19 | package Term::CLI::L10N 0.061001; | ||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||
| 21 | 20 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 22 | 20 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||
| 24 | 20 | ▶ | use parent 0.225 qw( Locale::Maketext Exporter ); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||
| 26 | 20 | ▶ | use Carp qw( croak ); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||
| 28 | 20 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||
| 30 | 20 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 31 | 20 | our @EXPORT_OK = qw( __ loc ); | |||||||||||||||||||||||||||||||||
| 32 | 20 | our %EXPORT_TAGS = ( 'all' => \@EXPORT_OK ); | |||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||
| 35 | 20 | my $lh; | |||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||
| 37 | 222 | ▶ | sub _init_handle { | ||||||||||||||||||||||||||||||||
|
Subroutine
_init_handle: called CC=4 SCAR=15.6
| |||||||||||||||||||||||||||||||||||
| 38 | 222 | ▶ | $lh //= __PACKAGE__->get_handle() || __PACKAGE__->get_handle('en'); | ||||||||||||||||||||||||||||||||
|
Condition50%3/6
$lh //= __PACKAGE__->get_handle || __PACKAGE__->get_handle("en")
__PACKAGE__->get_handle || __PACKAGE__->get_handle('en')
MC/DC0%0/3
$lh //= __PACKAGE__->get_handle || __PACKAGE__->get_handle("en")
$lh
__PACKAGE__->get_handle
__PACKAGE__->get_handle('en')
Truth table0%0/4
A //= B || C
A= $lhB= __PACKAGE__->get_handleC= __PACKAGE__->get_handle('en')
| |||||||||||||||||||||||||||||||||||
| 39 | 222 | ▶ | $lh or croak "No language files for 'en'"; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 40 | 222 | return $lh; | |||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||
| 43 | 20 | *__ = \&loc; # Alias __ to loc(). | |||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||
| 45 | 150 | ▶ | sub handle { | ||||||||||||||||||||||||||||||||
|
Subroutine
handle: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 46 | 150 | return _init_handle(); | |||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||
| 49 | 72 | ▶ | sub loc { | ||||||||||||||||||||||||||||||||
|
Subroutine
loc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 50 | 72 | _init_handle(); | |||||||||||||||||||||||||||||||||
| 51 | 72 | return $lh->SUPER::maketext(@_); | |||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||
| 54 | 15 | ▶ | sub set_language { | ||||||||||||||||||||||||||||||||
|
Subroutine
set_language: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 55 | 15 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||
| 57 | 15 | ▶ | $lh = __PACKAGE__->get_handle(@args) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 58 | or croak "No language files for (@args)"; | ||||||||||||||||||||||||||||||||||
| 59 | 15 | return $lh; | |||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||
| 62 | 20 | 1; | |||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||
| 64 | __END__ | ||||||||||||||||||||||||||||||||||