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