| 1 | # Copyright 2009, 2010, 2011, 2013, 2016 Kevin Ryde | ||||||||||||||
| 2 | |||||||||||||||
| 3 | # This file is part of Time-Duration-Locale. | ||||||||||||||
| 4 | # | ||||||||||||||
| 5 | # Time-Duration-Locale is free software; you can redistribute it and/or | ||||||||||||||
| 6 | # modify it under the terms of the GNU General Public License as published | ||||||||||||||
| 7 | # by the Free Software Foundation; either version 3, or (at your option) any | ||||||||||||||
| 8 | # later version. | ||||||||||||||
| 9 | # | ||||||||||||||
| 10 | # Time-Duration-Locale is distributed in the hope that it will be useful, | ||||||||||||||
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||||||||||||||
| 13 | # Public License for more details. | ||||||||||||||
| 14 | # | ||||||||||||||
| 15 | # You should have received a copy of the GNU General Public License along | ||||||||||||||
| 16 | # with Time-Duration-Locale. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||
| 17 | |||||||||||||||
| 18 | # cf Lingua::FI::Kontti too | ||||||||||||||
| 19 | |||||||||||||||
| 20 | package Time::Duration::en_PIGLATIN; | ||||||||||||||
| 21 | 2 | ▶ | use 5.004; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 22 | 2 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 23 | 2 | ▶ | use Time::Duration::Filter; # from => 'Time::Duration'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 24 | |||||||||||||||
| 25 | 2 | ▶ | use vars '$VERSION'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 26 | 2 | $VERSION = 12; | |||||||||||||
| 27 | |||||||||||||||
| 28 | 27 | ▶ | sub _filter { | ||||||||||||
|
Subroutine
_filter: called CC=3 SCAR=11.0
| |||||||||||||||
| 29 | 27 | my ($str) = @_; | |||||||||||||
| 30 | |||||||||||||||
| 31 | # Could do something for apostrophe in the middle of a word, but that | ||||||||||||||
| 32 | # doesn't arise from Time::Duration. | ||||||||||||||
| 33 | 27 | $str =~ s{([[:alpha:]]+)}{ | |||||||||||||
| 34 | 47 | my $word = $1; | |||||||||||||
| 35 | 47 | my $ret; | |||||||||||||
| 36 | 47 | ▶ | if ($word =~ /^(([bcdfghjklmnprstvwxz]|qu?)+)([aeiouy].*)/i) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 37 | # leading consonants to end | ||||||||||||||
| 38 | 35 | $ret = $3 . $1 . 'ay'; | |||||||||||||
| 39 | } elsif ($word =~ /[aeiouy]$/i) { | ||||||||||||||
| 40 | # ending in a vowel | ||||||||||||||
| 41 | 8 | $ret = $word . 'way'; | |||||||||||||
| 42 | } else { | ||||||||||||||
| 43 | # ending in a consonant | ||||||||||||||
| 44 | 4 | $ret = $word . 'ay'; | |||||||||||||
| 45 | } | ||||||||||||||
| 46 | 47 | _follow_caps ($word, $ret); | |||||||||||||
| 47 | }egi; | ||||||||||||||
| 48 | 27 | return $str; | |||||||||||||
| 49 | } | ||||||||||||||
| 50 | |||||||||||||||
| 51 | # Return $str with upper, lower or ucfirst case following what $orig has. | ||||||||||||||
| 52 | # If $orig is a single upper case char then it's treated as ucfirst. | ||||||||||||||
| 53 | 47 | ▶ | sub _follow_caps { | ||||||||||||
|
Subroutine
_follow_caps: called CC=3 SCAR=11.0
| |||||||||||||||
| 54 | 47 | my ($orig, $str) = @_; | |||||||||||||
| 55 | 47 | ▶ | return ($orig =~ /^[[:upper:]](.*[[:lower:]]|$)/ ? ucfirst(lc($str)) | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 56 | : $orig =~ /[[:lower:]]/ ? lc($str) | ||||||||||||||
| 57 | : uc($str)); | ||||||||||||||
| 58 | } | ||||||||||||||
| 59 | |||||||||||||||
| 60 | # Text::Bastardize 0.08 has a bug where pig() goes into an infinite loop on | ||||||||||||||
| 61 | # a word with no vowels like a number "20" etc from Time::Duration ... | ||||||||||||||
| 62 | # | ||||||||||||||
| 63 | # use Text::Bastardize; | ||||||||||||||
| 64 | # my $bastardizer = Text::Bastardize->new; | ||||||||||||||
| 65 | # sub _pig { | ||||||||||||||
| 66 | # my ($str) = @_; | ||||||||||||||
| 67 | # $bastardizer->charge ($str); | ||||||||||||||
| 68 | # return $bastardizer->pig; | ||||||||||||||
| 69 | # } | ||||||||||||||
| 70 | |||||||||||||||
| 71 | # use Time::Duration (); | ||||||||||||||
| 72 | # use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); | ||||||||||||||
| 73 | # | ||||||||||||||
| 74 | # $VERSION = 7; | ||||||||||||||
| 75 | # | ||||||||||||||
| 76 | # use Exporter; | ||||||||||||||
| 77 | # @ISA = ('Exporter'); | ||||||||||||||
| 78 | # | ||||||||||||||
| 79 | # @EXPORT = @Time::Duration::EXPORT; | ||||||||||||||
| 80 | # @EXPORT_OK = @Time::Duration::EXPORT_OK; | ||||||||||||||
| 81 | # %EXPORT_TAGS = (all => \@EXPORT_OK); | ||||||||||||||
| 82 | # | ||||||||||||||
| 83 | # foreach my $name (@EXPORT_OK) { | ||||||||||||||
| 84 | # eval "sub $name { _pig (Time::Duration::$name (\@_)) }"; | ||||||||||||||
| 85 | # } | ||||||||||||||
| 86 | |||||||||||||||
| 87 | 2 | 1; | |||||||||||||
| 88 | __END__ | ||||||||||||||