line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::Types::Locale::Language::Fast; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# **************************************************************** |
5
|
|
|
|
|
|
|
# general dependency(-ies) |
6
|
|
|
|
|
|
|
# **************************************************************** |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
776449
|
use 5.008_001; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
42
|
|
9
|
|
|
|
|
|
|
# MooseX::Types turns strict/warnings pragmas on, |
10
|
|
|
|
|
|
|
# however, kwalitee scorer can not detect such mechanism. |
11
|
|
|
|
|
|
|
# (Perl::Critic can it, with equivalent_modules parameter) |
12
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
13
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
1007
|
use Locale::Language; |
|
1
|
|
|
|
|
356484
|
|
|
1
|
|
|
|
|
101
|
|
16
|
1
|
|
|
|
|
11
|
use MooseX::Types::Moose qw( |
17
|
|
|
|
|
|
|
Str |
18
|
1
|
|
|
1
|
|
6661
|
); |
|
1
|
|
|
|
|
72772
|
|
19
|
|
|
|
|
|
|
use MooseX::Types ( |
20
|
1
|
|
|
|
|
8
|
-declare => [qw( |
21
|
|
|
|
|
|
|
LanguageCode |
22
|
|
|
|
|
|
|
Alpha2Language |
23
|
|
|
|
|
|
|
BibliographicLanguage |
24
|
|
|
|
|
|
|
Alpha3Language |
25
|
|
|
|
|
|
|
TerminologicLanguage |
26
|
|
|
|
|
|
|
LanguageName |
27
|
|
|
|
|
|
|
)], |
28
|
1
|
|
|
1
|
|
5890
|
); |
|
1
|
|
|
|
|
3
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# **************************************************************** |
32
|
|
|
|
|
|
|
# namespace clearer |
33
|
|
|
|
|
|
|
# **************************************************************** |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
1
|
|
7674
|
use namespace::clean; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# **************************************************************** |
39
|
|
|
|
|
|
|
# public class variable(s) |
40
|
|
|
|
|
|
|
# **************************************************************** |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
our $VERSION = "0.07"; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# **************************************************************** |
46
|
|
|
|
|
|
|
# subtype(s) and coercion(s) |
47
|
|
|
|
|
|
|
# **************************************************************** |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
50
|
|
|
|
|
|
|
# language code as defined in ISO 639-1 |
51
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
52
|
|
|
|
|
|
|
foreach my $subtype (LanguageCode, Alpha2Language) { |
53
|
|
|
|
|
|
|
subtype $subtype, |
54
|
|
|
|
|
|
|
as Str, |
55
|
|
|
|
|
|
|
where { |
56
|
|
|
|
|
|
|
code2language($_); |
57
|
|
|
|
|
|
|
}, |
58
|
|
|
|
|
|
|
message { |
59
|
|
|
|
|
|
|
sprintf 'Validation failed for code failed with value (%s) ' |
60
|
|
|
|
|
|
|
.'because specified language code does not exist ' |
61
|
|
|
|
|
|
|
. 'in ISO 639-1', |
62
|
|
|
|
|
|
|
defined $_ ? $_ : q{}; |
63
|
|
|
|
|
|
|
}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
67
|
|
|
|
|
|
|
# language code as defined in ISO 639-2 (alpha-3 bibliographic) |
68
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
69
|
|
|
|
|
|
|
foreach my $subtype (Alpha3Language, BibliographicLanguage) { |
70
|
|
|
|
|
|
|
subtype $subtype, |
71
|
|
|
|
|
|
|
as Str, |
72
|
|
|
|
|
|
|
where { |
73
|
|
|
|
|
|
|
code2language($_, LOCALE_LANG_ALPHA_3); |
74
|
|
|
|
|
|
|
}, |
75
|
|
|
|
|
|
|
message { |
76
|
|
|
|
|
|
|
sprintf 'Validation failed for code failed with value (%s) ' |
77
|
|
|
|
|
|
|
. 'because specified language code does not exist ' |
78
|
|
|
|
|
|
|
. 'in ISO 639-2 (bibliographic)', |
79
|
|
|
|
|
|
|
defined $_ ? $_ : q{}; |
80
|
|
|
|
|
|
|
}; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
84
|
|
|
|
|
|
|
# language code as defined in ISO 639-2 (alpha-3 terminologic) |
85
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
86
|
|
|
|
|
|
|
subtype TerminologicLanguage, |
87
|
|
|
|
|
|
|
as Str, |
88
|
|
|
|
|
|
|
where { |
89
|
|
|
|
|
|
|
code2language($_, LOCALE_LANG_TERM); |
90
|
|
|
|
|
|
|
}, |
91
|
|
|
|
|
|
|
message { |
92
|
|
|
|
|
|
|
sprintf 'Validation failed for code failed with value (%s) ' |
93
|
|
|
|
|
|
|
. 'because specified language code does not exist ' |
94
|
|
|
|
|
|
|
. 'in ISO 639-2 (terminology)', |
95
|
|
|
|
|
|
|
defined $_ ? $_ : q{}; |
96
|
|
|
|
|
|
|
}; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
99
|
|
|
|
|
|
|
# language name as defined in ISO 639 |
100
|
|
|
|
|
|
|
# ---------------------------------------------------------------- |
101
|
|
|
|
|
|
|
subtype LanguageName, |
102
|
|
|
|
|
|
|
as Str, |
103
|
|
|
|
|
|
|
where { |
104
|
|
|
|
|
|
|
language2code($_); |
105
|
|
|
|
|
|
|
}, |
106
|
|
|
|
|
|
|
message { |
107
|
|
|
|
|
|
|
sprintf 'Validation failed for name failed with value (%s) ' |
108
|
|
|
|
|
|
|
. 'because specified language name does not exist ' |
109
|
|
|
|
|
|
|
. 'in ISO 639', |
110
|
|
|
|
|
|
|
defined $_ ? $_ : q{}; |
111
|
|
|
|
|
|
|
}; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# **************************************************************** |
115
|
|
|
|
|
|
|
# optionally add Getopt option type |
116
|
|
|
|
|
|
|
# **************************************************************** |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
eval { require MooseX::Getopt; }; |
119
|
|
|
|
|
|
|
if (!$@) { |
120
|
|
|
|
|
|
|
MooseX::Getopt::OptionTypeMap->add_option_type_to_map( $_, '=s', ) |
121
|
|
|
|
|
|
|
for (LanguageCode, Alpha2Language, LanguageName); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# **************************************************************** |
126
|
|
|
|
|
|
|
# return true |
127
|
|
|
|
|
|
|
# **************************************************************** |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |
130
|
|
|
|
|
|
|
__END__ |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# **************************************************************** |
134
|
|
|
|
|
|
|
# POD |
135
|
|
|
|
|
|
|
# **************************************************************** |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=pod |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 NAME |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
MooseX::Types::Locale::Language::Fast - Locale::Language related constraints for Moose (without coercions) |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 VERSION |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This document describes |
146
|
|
|
|
|
|
|
L<MooseX::Types::Locale::Language::Fast|MooseX::Types::Locale::Language::Fast> |
147
|
|
|
|
|
|
|
version C<0.07>. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 SYNOPSIS |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
{ |
152
|
|
|
|
|
|
|
package Foo; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
use Moose; |
155
|
|
|
|
|
|
|
use MooseX::Types::Locale::Language qw( |
156
|
|
|
|
|
|
|
LanguageCode |
157
|
|
|
|
|
|
|
LanguageName |
158
|
|
|
|
|
|
|
); |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
has 'code' |
161
|
|
|
|
|
|
|
=> ( isa => LanguageCode, is => 'rw' ); |
162
|
|
|
|
|
|
|
has 'name' |
163
|
|
|
|
|
|
|
=> ( isa => LanguageName, is => 'rw' ); |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
my $foo = Foo->new( |
169
|
|
|
|
|
|
|
code => 'JA', |
170
|
|
|
|
|
|
|
name => 'JAPANESE', |
171
|
|
|
|
|
|
|
); |
172
|
|
|
|
|
|
|
print $foo->code; # 'JA' (not 'ja') |
173
|
|
|
|
|
|
|
print $foo->name; # 'JAPANESE' (not 'Japanese') |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 DESCRIPTION |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
This module packages several |
178
|
|
|
|
|
|
|
L<Moose::Util::TypeConstraints|Moose::Util::TypeConstraints>, |
179
|
|
|
|
|
|
|
designed to work with the values of L<Locale::Language|Locale::Language>. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
This module does not provide you coercions. |
182
|
|
|
|
|
|
|
Therefore, it works faster than |
183
|
|
|
|
|
|
|
L<MooseX::Types::Locale::Language|MooseX::Types::Locale::Language>. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 CONSTRAINTS |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=over 4 |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item C<Alpha2Language> |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
A subtype of C<Str>, which should be defined in language code of ISO 639-1 |
192
|
|
|
|
|
|
|
alpha-2. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=item C<LanguageCode> |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Alias of C<Alpha2Language>. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=item C<BibliographicLanguage> |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
A subtype of C<Str>, which should be defined in language code of ISO 639-2/B |
201
|
|
|
|
|
|
|
alpha-3. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=item C<Alpha3Language> |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Alias of C<BibliographicLanguage>. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=item C<TerminologicLanguage> |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
A subtype of C<Str>, which should be defined in language code of ISO 639-2/T |
210
|
|
|
|
|
|
|
alpha-3. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=item C<LanguageName> |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
A subtype of C<Str>, which should be defined in ISO 639-1 language name. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=back |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head1 NOTE |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head2 The type mapping of L<MooseX::Getopt|MooseX::Getopt> |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
This module provides the optional type mapping of |
223
|
|
|
|
|
|
|
L<MooseX::Getopt|MooseX::Getopt> |
224
|
|
|
|
|
|
|
when L<MooseX::Getopt|MooseX::Getopt> was installed. |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
C<LanguageCode>, C<Alpha2Language> and C<LanguageName> are |
227
|
|
|
|
|
|
|
C<String> (C<"=s">) type. |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head1 SEE ALSO |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=over 4 |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=item * L<Locale::Language|Locale::Language> |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=item * L<MooseX::Types::Locale::Language|MooseX::Types::Locale::Language> |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=item * L<MooseX::Types::Locale::Country::Fast|MooseX::Types::Locale::Country::Fast> |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=back |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head1 TO DO |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
See L<TO DO section of MooseX::Types::Locale::Language|MooseX::Types::Locale::Language/TO_DO>. |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
None reported. |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
No bugs have been reported. |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=head2 Making suggestions and reporting bugs |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
Please report any found bugs, feature requests, and ideas for improvements |
256
|
|
|
|
|
|
|
to C<bug-moosex-types-locale-language at rt.cpan.org>, |
257
|
|
|
|
|
|
|
or through the web interface |
258
|
|
|
|
|
|
|
at L<http://rt.cpan.org/Public/Bug/Report.html?Queue=MooseX-Types-Locale-Language>. |
259
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress |
260
|
|
|
|
|
|
|
on your bugs/requests as I make changes. |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
When reporting bugs, if possible, |
263
|
|
|
|
|
|
|
please add as small a sample as you can make of the code |
264
|
|
|
|
|
|
|
that produces the bug. |
265
|
|
|
|
|
|
|
And of course, suggestions and patches are welcome. |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=head1 SUPPORT |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
You can find documentation for this module with the C<perldoc> command. |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
perldoc MooseX::Types::Locale::Language::Fast |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
You can also look for information at: |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=over 4 |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=item RT: CPAN's request tracker |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
L<http://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Types-Locale-Language> |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=item AnnoCPAN: Annotated CPAN documentation |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
L<http://annocpan.org/dist/MooseX-Types-Locale-Language> |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=item Search CPAN |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/MooseX-Types-Locale-Language> |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
=item CPAN Ratings |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/dist/MooseX-Types-Locale-Language> |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=back |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=head1 VERSION CONTROL |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
This module is maintained using I<git>. |
298
|
|
|
|
|
|
|
You can get the latest version from |
299
|
|
|
|
|
|
|
L<git://github.com/gardejo/p5-moosex-types-locale-language.git>. |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
=head1 AUTHOR |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
=over 4 |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=item MORIYA Masaki, alias Gardejo |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
C<< <moriya at cpan dot org> >>, |
308
|
|
|
|
|
|
|
L<http://gardejo.org/> |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=back |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
Copyright (c) 2009-2010 MORIYA Masaki, alias Gardejo |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
This library is free software; |
317
|
|
|
|
|
|
|
you can redistribute it and/or modify it under the same terms as Perl itself. |
318
|
|
|
|
|
|
|
See L<perlgpl|perlgpl> and L<perlartistic|perlartistic>. |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
The full text of the license can be found in the F<LICENSE> file |
321
|
|
|
|
|
|
|
included with this distribution. |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
=cut |