line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::WOVN::Lang; |
2
|
2
|
|
|
2
|
|
409
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
44
|
|
3
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
35
|
|
4
|
2
|
|
|
2
|
|
6
|
use utf8; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
7
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#http://msdn.microsoft.com/en-us/library/hh456380.aspx |
7
|
|
|
|
|
|
|
our $LANG = { |
8
|
|
|
|
|
|
|
'ar' => { name => 'ﺎﻠﻋﺮﺒﻳﺓ', code => 'ar', en => 'Arabic' }, |
9
|
|
|
|
|
|
|
'bg' => { name => 'Български', code => 'bg', en => 'Bulgarian' }, |
10
|
|
|
|
|
|
|
'zh-CHS' => |
11
|
|
|
|
|
|
|
{ name => '简体中文', code => 'zh-CHS', en => 'Simp Chinese' }, |
12
|
|
|
|
|
|
|
'zh-CHT' => |
13
|
|
|
|
|
|
|
{ name => '繁體中文', code => 'zh-CHT', en => 'Trad Chinese' }, |
14
|
|
|
|
|
|
|
'da' => { name => 'Dansk', code => 'da', en => 'Danish' }, |
15
|
|
|
|
|
|
|
'nl' => { name => 'Nederlands', code => 'nl', en => 'Dutch' }, |
16
|
|
|
|
|
|
|
'en' => { name => 'English', code => 'en', en => 'English' }, |
17
|
|
|
|
|
|
|
'fi' => { name => 'Suomi', code => 'fi', en => 'Finnish' }, |
18
|
|
|
|
|
|
|
'fr' => { name => 'Français', code => 'fr', en => 'French' }, |
19
|
|
|
|
|
|
|
'de' => { name => 'Deutsch', code => 'de', en => 'German' }, |
20
|
|
|
|
|
|
|
'el' => { name => 'Ελληνικά', code => 'el', en => 'Greek' }, |
21
|
|
|
|
|
|
|
'he' => { name => 'עברית', code => 'he', en => 'Hebrew' }, |
22
|
|
|
|
|
|
|
'id' => { name => 'Bahasa Indonesia', code => 'id', en => 'Indonesian' }, |
23
|
|
|
|
|
|
|
'it' => { name => 'Italiano', code => 'it', en => 'Italian' }, |
24
|
|
|
|
|
|
|
'ja' => { name => '日本語', code => 'ja', en => 'Japanese' }, |
25
|
|
|
|
|
|
|
'ko' => { name => '한국어', code => 'ko', en => 'Korean' }, |
26
|
|
|
|
|
|
|
'ms' => { name => 'Bahasa Melayu', code => 'ms', en => 'Malay' }, |
27
|
|
|
|
|
|
|
'no' => { name => 'Norsk', code => 'no', en => 'Norwegian' }, |
28
|
|
|
|
|
|
|
'pl' => { name => 'Polski', code => 'pl', en => 'Polish' }, |
29
|
|
|
|
|
|
|
'pt' => { name => 'Português', code => 'pt', en => 'Portuguese' }, |
30
|
|
|
|
|
|
|
'ru' => { name => 'Русский', code => 'ru', en => 'Russian' }, |
31
|
|
|
|
|
|
|
'es' => { name => 'Español', code => 'es', en => 'Spanish' }, |
32
|
|
|
|
|
|
|
'sv' => { name => 'Svensk', code => 'sv', en => 'Swedish' }, |
33
|
|
|
|
|
|
|
'th' => { name => 'ภาษาไทย', code => 'th', en => 'Thai' }, |
34
|
|
|
|
|
|
|
'hi' => { name => 'हिन्दी', code => 'hi', en => 'Hindi' }, |
35
|
|
|
|
|
|
|
'tr' => { name => 'Türkçe', code => 'tr', en => 'Turkish' }, |
36
|
|
|
|
|
|
|
'uk' => |
37
|
|
|
|
|
|
|
{ name => 'Українська', code => 'uk', en => 'Ukrainian' }, |
38
|
|
|
|
|
|
|
'vi' => { name => 'Tiếng Việt', code => 'vi', en => 'Vietnamese' }, |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub get_code { |
42
|
8
|
|
|
8
|
0
|
31713
|
my ( $class, $lang_name ) = @_; |
43
|
8
|
100
|
|
|
|
17
|
return undef unless defined $lang_name; |
44
|
7
|
100
|
|
|
|
19
|
return $lang_name if $LANG->{$lang_name}; |
45
|
|
|
|
|
|
|
|
46
|
5
|
|
|
|
|
112
|
$lang_name = lc $lang_name; |
47
|
|
|
|
|
|
|
|
48
|
5
|
|
|
|
|
21
|
for my $key ( keys %$LANG ) { |
49
|
1
|
100
|
100
|
1
|
|
5
|
if ( $lang_name eq lc $LANG->{$key}{name} |
|
1
|
|
100
|
|
|
1
|
|
|
1
|
|
|
|
|
10
|
|
|
115
|
|
|
|
|
17939
|
|
50
|
|
|
|
|
|
|
|| $lang_name eq lc $LANG->{$key}{en} |
51
|
|
|
|
|
|
|
|| $lang_name eq lc $LANG->{$key}{code} ) |
52
|
|
|
|
|
|
|
{ |
53
|
3
|
|
|
|
|
12
|
return $LANG->{$key}{code}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
2
|
|
|
|
|
10
|
return undef; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub get_lang { |
61
|
1
|
|
|
1
|
0
|
2
|
my ( $class, $lang ) = @_; |
62
|
1
|
|
|
|
|
2
|
my $lang_code = $class->get_code($lang); |
63
|
1
|
50
|
|
|
|
47
|
$lang_code ? $LANG->{$lang_code} : undef; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |