| 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
| |||||||||||
| 43 | 36 | ▶ | s/ven$/f/x and return $_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | |||||||||||
| 45 | # -eu?en, -ei?en | ||||||||||
| 46 | 35 | ▶ | s/(eu|ei)([^aeiou])en$/$1$2/x and return $_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | |||||||||||
| 48 | # gelegenheden -> gelegenheid | ||||||||||
| 49 | 34 | ▶ | s/heden$/heid/x and return $_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | |||||||||||
| 51 | # musea -> museum | ||||||||||
| 52 | # aquaria -> aquarium | ||||||||||
| 53 | 33 | ▶ | s/([ei])a$/$1um/x and return $_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | |||||||||||
| 55 | # rijen -> rij | ||||||||||
| 56 | 30 | ▶ | s/ijen$/ij/x and return $_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | |||||||||||
| 58 | # leraren -> leraar | ||||||||||
| 59 | 29 | ▶ | s/([aeiou])([^aeiou])en$/$1$1$2/x and return $_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | |||||||||||
| 61 | # ballen -> bal | ||||||||||
| 62 | 25 | ▶ | s/([^aeiou])\1en$/$1/x and return $_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 82 | |||||||||||
| 83 | 148 | ▶ | if (@forms > 1) { # Both plural and singular are supplied | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | 74 | ▶ | return $is_plural ? $forms[0] : $forms[1]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 85 | } | ||||||||||
| 86 | |||||||||||
| 87 | # Only plural specified | ||||||||||
| 88 | 74 | my $word = $forms[0]; | |||||||||
| 89 | 74 | ▶ | if ($is_plural) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 90 | 37 | return $word; | |||||||||
| 91 | } | ||||||||||
| 92 | 37 | return $handle->singularize($word); | |||||||||
| 93 | } | ||||||||||
| 94 | |||||||||||
| 95 | 1 | 1; | |||||||||
| 96 | |||||||||||
| 97 | __DATA__ | ||||||||||