line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
19
|
|
|
19
|
|
101755
|
use v5.14; |
|
19
|
|
|
|
|
79
|
|
2
|
19
|
|
|
19
|
|
108
|
use warnings; |
|
19
|
|
|
|
|
43
|
|
|
19
|
|
|
|
|
1014
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Test::BDD::Cucumber::I18n 0.86; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=encoding utf8 |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Test::BDD::Cucumber::I18N - Internationalization |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
version 0.86 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Internationalization of feature files and step definitions. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use Test::BDD::Cucumber::I18n |
23
|
|
|
|
|
|
|
qw(languages has_language langdef); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# get codes of supported languages |
26
|
|
|
|
|
|
|
my @supported_languages = languages(); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# look up if a language is supported |
29
|
|
|
|
|
|
|
my $language_is_supported = has_language('de'); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# get definition of a language |
32
|
|
|
|
|
|
|
my $langdef = langdef('de'); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# get readable keyword definitions |
35
|
|
|
|
|
|
|
my $string = readable_keywords |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
19
|
|
|
19
|
|
8718
|
use utf8; |
|
19
|
|
|
|
|
252
|
|
|
19
|
|
|
|
|
108
|
|
40
|
|
|
|
|
|
|
|
41
|
19
|
|
|
19
|
|
677
|
use base 'Exporter'; |
|
19
|
|
|
|
|
53
|
|
|
19
|
|
|
|
|
3039
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
our @EXPORT_OK = |
44
|
|
|
|
|
|
|
qw(languages langdef has_language readable_keywords keyword_to_subname); |
45
|
|
|
|
|
|
|
|
46
|
19
|
|
|
19
|
|
10147
|
use Test::BDD::Cucumber::I18N::Data; |
|
19
|
|
|
|
|
210
|
|
|
19
|
|
|
|
|
6925
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 METHODS |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 languages |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Get codes of supported languages. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub languages { |
57
|
14
|
|
|
14
|
1
|
741
|
return sort keys %Test::BDD::Cucumber::I18N::Data::languages; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 has_language($language) |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Check if a language is supported. Takes as argument the language |
63
|
|
|
|
|
|
|
abbreviation defined in C. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub has_language { |
68
|
1053
|
|
|
1053
|
1
|
1556
|
my ($language) = @_; |
69
|
1053
|
|
|
|
|
2775
|
return exists $Test::BDD::Cucumber::I18N::Data::languages{$language}; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 langdef($language) |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Get definition of a language. Takes as argument the language abbreviation |
75
|
|
|
|
|
|
|
defined in C. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub langdef { |
80
|
1053
|
|
|
1053
|
1
|
2161
|
my ($language) = @_; |
81
|
|
|
|
|
|
|
|
82
|
1053
|
50
|
|
|
|
1757
|
return unless has_language($language); |
83
|
1053
|
|
|
|
|
2428
|
return $Test::BDD::Cucumber::I18N::Data::languages{$language}; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 readable_keywords($string, $transform) |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Get readable keyword definitions. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub readable_keywords { |
93
|
0
|
|
|
0
|
1
|
0
|
my ( $string, $transform ) = @_; |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
0
|
my @keywords = split( /\|/, $string ); |
96
|
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
0
|
@keywords = map { $transform->($_) } @keywords if $transform; |
|
0
|
|
|
|
|
0
|
|
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
0
|
return join( ', ', map { '"' . $_ . '"' } @keywords ); |
|
0
|
|
|
|
|
0
|
|
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 keyword_to_subname |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Return a keyword into a subname with non-word characters removed. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub keyword_to_subname { |
109
|
5109
|
|
|
5109
|
1
|
8308
|
my ($word) = @_; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# remove non-word characters so we have a decent sub name |
112
|
18
|
|
|
18
|
|
127
|
$word =~ s{[^\p{Word}]}{}g; |
|
18
|
|
|
|
|
44
|
|
|
18
|
|
|
|
|
249
|
|
|
5109
|
|
|
|
|
18017
|
|
113
|
|
|
|
|
|
|
|
114
|
5109
|
|
|
|
|
11799
|
return $word; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 LANGUAGES |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Languages are defined in L, and have been |
120
|
|
|
|
|
|
|
lifted from the Gherkin distribution. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 AUTHOR |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Gregor Goldbach C |
125
|
|
|
|
|
|
|
(based on the works of Pablo Duboue) |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 LICENSE |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Copyright 2019-2023, Erik Huelsmann |
130
|
|
|
|
|
|
|
Copyright 2014-2019, Gregor Goldbach; Licensed under the same terms as Perl |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
1; |