line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DDG::Test::Language; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:DDG'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Gives functions for getting test L objects. |
4
|
|
|
|
|
|
|
$DDG::Test::Language::VERSION = '1018'; |
5
|
8
|
|
|
13
|
|
60
|
use strict; |
|
8
|
|
|
|
|
20
|
|
|
8
|
|
|
|
|
274
|
|
6
|
8
|
|
|
8
|
|
50
|
use warnings; |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
308
|
|
7
|
8
|
|
|
8
|
|
2539
|
use DDG::Language; |
|
8
|
|
|
|
|
34
|
|
|
8
|
|
|
|
|
375
|
|
8
|
8
|
|
|
8
|
|
84
|
use Package::Stash; |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
219
|
|
9
|
8
|
|
|
8
|
|
44
|
use utf8; |
|
8
|
|
|
|
|
22
|
|
|
8
|
|
|
|
|
66
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our %languages = ( |
13
|
|
|
|
|
|
|
'us' => { |
14
|
|
|
|
|
|
|
'flagicon' => 'us', |
15
|
|
|
|
|
|
|
'flag_url' => 'https://duckduckgo.com/f2/us.png', |
16
|
|
|
|
|
|
|
'name_in_local' => 'English of United States', |
17
|
|
|
|
|
|
|
'rtl' => 0, |
18
|
|
|
|
|
|
|
'locale' => 'en_US', |
19
|
|
|
|
|
|
|
'nplurals' => 2, |
20
|
|
|
|
|
|
|
'name_in_english' => 'English of United States', |
21
|
|
|
|
|
|
|
}, |
22
|
|
|
|
|
|
|
'de' => { |
23
|
|
|
|
|
|
|
'flagicon' => 'de', |
24
|
|
|
|
|
|
|
'flag_url' => 'https://duckduckgo.com/f2/de.png', |
25
|
|
|
|
|
|
|
'name_in_local' => 'Deutsch von Deutschland', |
26
|
|
|
|
|
|
|
'rtl' => 0, |
27
|
|
|
|
|
|
|
'locale' => 'de_DE', |
28
|
|
|
|
|
|
|
'nplurals' => 2, |
29
|
|
|
|
|
|
|
'name_in_english' => 'German of Germany', |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
'my' => { |
32
|
|
|
|
|
|
|
'flagicon' => 'my', |
33
|
|
|
|
|
|
|
'flag_url' => 'https://duckduckgo.com/f2/my.png', |
34
|
|
|
|
|
|
|
'name_in_local' => 'Bahasa Malaysia di Malaysia', |
35
|
|
|
|
|
|
|
'rtl' => 0, |
36
|
|
|
|
|
|
|
'locale' => 'ms_MY', |
37
|
|
|
|
|
|
|
'nplurals' => 1, |
38
|
|
|
|
|
|
|
'name_in_english' => 'Malay in Malaysia', |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub import { |
43
|
9
|
|
|
9
|
|
41
|
my ( $class, %params ) = @_; |
44
|
9
|
|
|
|
|
26
|
my $target = caller; |
45
|
9
|
|
|
|
|
123
|
my $stash = Package::Stash->new($target); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$stash->add_symbol('&test_language', sub { |
49
|
16
|
|
|
16
|
|
18760
|
my $language_key = shift; |
50
|
16
|
50
|
|
|
|
57
|
die "Unknown language_key \"".$language_key."\"" unless defined $languages{$language_key}; |
51
|
16
|
|
|
|
|
33
|
return DDG::Language->new( %{$languages{$language_key}} ); |
|
16
|
|
|
|
|
334
|
|
52
|
9
|
|
|
|
|
181
|
}); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$stash->add_symbol('&test_language_by_env', sub { |
56
|
0
|
0
|
|
0
|
|
|
my $language_key = defined $ENV{DDG_TEST_LANGUAGE} ? $ENV{DDG_TEST_LANGUAGE} : 'us'; |
57
|
0
|
|
|
|
|
|
$stash->get_symbol('&test_language')->($language_key); |
58
|
9
|
|
|
|
|
399
|
}); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |