CLI/L10N/nl.pm

filter: Statementstmt 100% 39 / 39 Branchbran 100% 24 / 24 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 100% 72 / 72 CC 13 SCAR 17.7
CC
13
Cov
100%
singularize
9.0
numerate
5.0
BEGIN
1.0
CRAP 5.8
« CLI/Argument/Number.pm ↑ Summary CLI/Role/CommandSet.pm »
1 #=============================================================================
2 #
3 # Module: Term::CLI::L10N::nl
4 # Author: Steven Bakker (SBAKKER), <cpanman@monkey-mind.net>
5 # Created: 27/02/18
6 #
7 # Copyright (c) 2018-2022 Steven Bakker; All rights reserved.
8 #
9 # This module is free software; you can redistribute it and/or modify
10 # it under the same terms as Perl itself. See "perldoc perlartistic."
11 #
12 # This software is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 #
16 #=============================================================================
17  
18 package Term::CLI::L10N::nl 0.061001;
19  
20 1 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 1 ▶use parent 0.225 qw( Term::CLI::L10N );
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 1 ▶use Locale::Maketext::Lexicon::Gettext 1.00;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 ## no critic (ProhibitPackageVars)
28 1 our %Lexicon = %{ Locale::Maketext::Lexicon::Gettext->parse(<DATA>) };
29 1 close DATA;
30  
31 # $str = $lh->singularize($num, $plural);
32 # $str = $lh->singularise($num, $plural);
33 1 ▶use subs 1.00 qw( singularise );
Subroutine BEGIN: called CC=1 SCAR=0.0
34 1 *singularise = \&singularize;
35  
36 37 ▶sub singularize {
Subroutine singularize: called CC=9 SCAR=22.0
Pod documented
37 37 my $self = shift;
38  
39 37 local ($_) = shift;
40  
41 # -zen, -ven -> -s, -f
42 37 ▶ s/zen$/s/x and return $_;
Branch: 1 branch
BranchTrueFalseTotal
s/zen$/s/ux and return $_ 1 36 37
43 36 ▶ s/ven$/f/x and return $_;
Branch: 1 branch
BranchTrueFalseTotal
s/ven$/f/ux and return $_ 1 35 36
44  
45 # -eu?en, -ei?en
46 35 ▶ s/(eu|ei)([^aeiou])en$/$1$2/x and return $_;
Branch: 1 branch
BranchTrueFalseTotal
s/(eu|ei)([^aeiou])en$/$1$2/ux and return $_ 1 34 35
47  
48 # gelegenheden -> gelegenheid
49 34 ▶ s/heden$/heid/x and return $_;
Branch: 1 branch
BranchTrueFalseTotal
s/heden$/heid/ux and return $_ 1 33 34
50  
51 # musea -> museum
52 # aquaria -> aquarium
53 33 ▶ s/([ei])a$/$1um/x and return $_;
Branch: 1 branch
BranchTrueFalseTotal
s/([ei])a$/$1um/ux and return $_ 3 30 33
54  
55 # rijen -> rij
56 30 ▶ s/ijen$/ij/x and return $_;
Branch: 1 branch
BranchTrueFalseTotal
s/ijen$/ij/ux and return $_ 1 29 30
57  
58 # leraren -> leraar
59 29 ▶ s/([aeiou])([^aeiou])en$/$1$1$2/x and return $_;
Branch: 1 branch
BranchTrueFalseTotal
s/([aeiou])([^aeiou])en$/$1$1$2/ux and return $_ 4 25 29
60  
61 # ballen -> bal
62 25 ▶ s/([^aeiou])\1en$/$1/x and return $_;
Branch: 1 branch
BranchTrueFalseTotal
s/([^aeiou])\1en$/$1/ux and return $_ 1 24 25
63  
64 # schermen -> scherm
65 # auto's -> auto
66 # lepels -> lepel
67 24 return s/(?:'?en|'s|s)$//rx;
68 }
69  
70 # $str = $lh->numerate($num, $plural [, $singular ]);
71 #
72 # NOTE: this reverses the semantics of the
73 # plural/singular forms, because it's easier
74 # to go from plural to singular in Dutch.
75 #
76 150 ▶sub numerate {
Subroutine numerate: called CC=5 SCAR=16.1
Pod documented
77 150 my ( $handle, $num, @forms ) = @_;
78  
79 150 my $is_plural = ( $num != 1 );
80  
81 150 ▶ return '' if @forms == 0;
Branch: 1 branch
BranchTrueFalseTotal
if @forms == 0 2 148 150
82  
83 148 ▶ if (@forms > 1) { # Both plural and singular are supplied
Branch: 1 branch
BranchTrueFalseTotal
if (@forms > 1) 74 74 148
84 74 ▶ return $is_plural ? $forms[0] : $forms[1];
Branch: 1 branch
BranchTrueFalseTotal
$is_plural ? : 37 37 74
85 }
86  
87 # Only plural specified
88 74 my $word = $forms[0];
89 74 ▶ if ($is_plural) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_plural) 37 37 74
90 37 return $word;
91 }
92 37 return $handle->singularize($word);
93 }
94  
95 1 1;
96  
97 __DATA__
« CLI/Argument/Number.pm ↑ Summary CLI/Role/CommandSet.pm »