line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Win32::Locale; |
3
|
|
|
|
|
|
|
# Time-stamp: "2004-01-11 18:56:06 AST" |
4
|
1
|
|
|
1
|
|
9792
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
45
|
|
5
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION %MSLocale2LangTag); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1572
|
|
6
|
|
|
|
|
|
|
$VERSION = '0.04'; |
7
|
|
|
|
|
|
|
%MSLocale2LangTag = ( |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
0x0436 => 'af' , # |
10
|
|
|
|
|
|
|
0x041c => 'sq' , # |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
0x0401 => 'ar-sa', # |
13
|
|
|
|
|
|
|
0x0801 => 'ar-iq', # |
14
|
|
|
|
|
|
|
0x0C01 => 'ar-eg', # |
15
|
|
|
|
|
|
|
0x1001 => 'ar-ly', # |
16
|
|
|
|
|
|
|
0x1401 => 'ar-dz', # |
17
|
|
|
|
|
|
|
0x1801 => 'ar-ma', # |
18
|
|
|
|
|
|
|
0x1C01 => 'ar-tn', # |
19
|
|
|
|
|
|
|
0x2001 => 'ar-om', # |
20
|
|
|
|
|
|
|
0x2401 => 'ar-ye', # |
21
|
|
|
|
|
|
|
0x2801 => 'ar-sy', # |
22
|
|
|
|
|
|
|
0x2C01 => 'ar-jo', # |
23
|
|
|
|
|
|
|
0x3001 => 'ar-lb', # |
24
|
|
|
|
|
|
|
0x3401 => 'ar-kw', # |
25
|
|
|
|
|
|
|
0x3801 => 'ar-ae', # |
26
|
|
|
|
|
|
|
0x3C01 => 'ar-bh', # |
27
|
|
|
|
|
|
|
0x4001 => 'ar-qa', # |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
0x042b => 'hy' , # |
30
|
|
|
|
|
|
|
0x044d => 'as' , # |
31
|
|
|
|
|
|
|
0x042c => 'az-latn', # |
32
|
|
|
|
|
|
|
0x082c => 'az-cyrl', # |
33
|
|
|
|
|
|
|
0x042D => 'eu' , # |
34
|
|
|
|
|
|
|
0x0423 => 'be' , # |
35
|
|
|
|
|
|
|
0x0445 => 'bn' , # |
36
|
|
|
|
|
|
|
0x0402 => 'bg' , # |
37
|
|
|
|
|
|
|
0x0403 => 'ca' , # |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Chinese is zh, not cn! |
40
|
|
|
|
|
|
|
0x0404 => 'zh-tw', # |
41
|
|
|
|
|
|
|
0x0804 => 'zh-cn', # |
42
|
|
|
|
|
|
|
0x0C04 => 'zh-hk', # |
43
|
|
|
|
|
|
|
0x1004 => 'zh-sg', # |
44
|
|
|
|
|
|
|
0x1404 => 'zh-mo', # |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
0x041a => 'hr' , # |
47
|
|
|
|
|
|
|
0x0405 => 'cs' , # |
48
|
|
|
|
|
|
|
0x0406 => 'da' , # |
49
|
|
|
|
|
|
|
0x0413 => 'nl-nl', # |
50
|
|
|
|
|
|
|
0x0813 => 'nl-be', # |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
0x0409 => 'en-us', # |
53
|
|
|
|
|
|
|
0x0809 => 'en-gb', # |
54
|
|
|
|
|
|
|
0x0c09 => 'en-au', # |
55
|
|
|
|
|
|
|
0x1009 => 'en-ca', # |
56
|
|
|
|
|
|
|
0x1409 => 'en-nz', # |
57
|
|
|
|
|
|
|
0x1809 => 'en-ie', # |
58
|
|
|
|
|
|
|
0x1c09 => 'en-za', # |
59
|
|
|
|
|
|
|
0x2009 => 'en-jm', # |
60
|
|
|
|
|
|
|
0x2409 => 'en-jm', # # a hack |
61
|
|
|
|
|
|
|
0x2809 => 'en-bz', # |
62
|
|
|
|
|
|
|
0x2c09 => 'en-tt', # |
63
|
|
|
|
|
|
|
0x3009 => 'en-zw', # |
64
|
|
|
|
|
|
|
0x3409 => 'en-ph', # |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
0x0425 => 'et' , # |
67
|
|
|
|
|
|
|
0x0438 => 'fo' , # |
68
|
|
|
|
|
|
|
0x0429 => 'pa' , # # =Persian |
69
|
|
|
|
|
|
|
0x040b => 'fi' , # |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
0x040c => 'fr-fr', # |
72
|
|
|
|
|
|
|
0x080c => 'fr-be', # |
73
|
|
|
|
|
|
|
0x0c0c => 'fr-ca', # |
74
|
|
|
|
|
|
|
0x100c => 'fr-ch', # |
75
|
|
|
|
|
|
|
0x140c => 'fr-lu', # |
76
|
|
|
|
|
|
|
0x180c => 'fr-mc', # |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
0x0437 => 'ka' , # |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
0x0407 => 'de-de', # |
81
|
|
|
|
|
|
|
0x0807 => 'de-ch', # |
82
|
|
|
|
|
|
|
0x0c07 => 'de-at', # |
83
|
|
|
|
|
|
|
0x1007 => 'de-lu', # |
84
|
|
|
|
|
|
|
0x1407 => 'de-li', # |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
0x0408 => 'el' , # |
87
|
|
|
|
|
|
|
0x0447 => 'gu' , # |
88
|
|
|
|
|
|
|
0x040D => 'he' , # # formerly 'iw' |
89
|
|
|
|
|
|
|
0x0439 => 'hi' , # |
90
|
|
|
|
|
|
|
0x040e => 'hu' , # |
91
|
|
|
|
|
|
|
0x040F => 'is' , # |
92
|
|
|
|
|
|
|
0x0421 => 'id' , # # formerly 'in' |
93
|
|
|
|
|
|
|
0x0410 => 'it-it', # |
94
|
|
|
|
|
|
|
0x0810 => 'it-ch', # |
95
|
|
|
|
|
|
|
0x0411 => 'ja' , # # not "jp"! |
96
|
|
|
|
|
|
|
0x044b => 'kn' , # |
97
|
|
|
|
|
|
|
0x0860 => 'ks' , # |
98
|
|
|
|
|
|
|
0x043f => 'kk' , # |
99
|
|
|
|
|
|
|
0x0457 => 'kok' , # 3-letters! |
100
|
|
|
|
|
|
|
0x0412 => 'ko' , # |
101
|
|
|
|
|
|
|
0x0812 => 'ko' , # ? |
102
|
|
|
|
|
|
|
0x0426 => 'lv' , # # = lettish |
103
|
|
|
|
|
|
|
0x0427 => 'lt' , # |
104
|
|
|
|
|
|
|
0x0827 => 'lt' , # ? |
105
|
|
|
|
|
|
|
0x042f => 'mk' , # |
106
|
|
|
|
|
|
|
0x043e => 'ms' , # |
107
|
|
|
|
|
|
|
0x083e => 'ms-bn', # |
108
|
|
|
|
|
|
|
0x044c => 'ml' , # |
109
|
|
|
|
|
|
|
0x044e => 'mr' , # |
110
|
|
|
|
|
|
|
0x0461 => 'ne-np', # |
111
|
|
|
|
|
|
|
0x0861 => 'ne-in', # |
112
|
|
|
|
|
|
|
0x0414 => 'nb' , # #was no-bok |
113
|
|
|
|
|
|
|
0x0814 => 'nn' , # #was no-nyn |
114
|
|
|
|
|
|
|
# note that this leaves nothing using "no" ("Norwegian") |
115
|
|
|
|
|
|
|
0x0448 => 'or' , # |
116
|
|
|
|
|
|
|
0x0415 => 'pl' , # |
117
|
|
|
|
|
|
|
0x0416 => 'pt-br', # |
118
|
|
|
|
|
|
|
0x0816 => 'pt-pt', # |
119
|
|
|
|
|
|
|
0x0446 => 'pa' , # |
120
|
|
|
|
|
|
|
0x0417 => 'rm' , # |
121
|
|
|
|
|
|
|
0x0418 => 'ro' , # |
122
|
|
|
|
|
|
|
0x0818 => 'ro-md', # |
123
|
|
|
|
|
|
|
0x0419 => 'ru' , # |
124
|
|
|
|
|
|
|
0x0819 => 'ru-md', # |
125
|
|
|
|
|
|
|
0x043b => 'se' , # assuming == "Northern Sami" |
126
|
|
|
|
|
|
|
0x044f => 'sa' , # |
127
|
|
|
|
|
|
|
0x0c1a => 'sr-cyrl', # |
128
|
|
|
|
|
|
|
0x081a => 'sr-latn', # |
129
|
|
|
|
|
|
|
0x0459 => 'sd' , # |
130
|
|
|
|
|
|
|
0x041b => 'sk' , # |
131
|
|
|
|
|
|
|
0x0424 => 'sl' , # |
132
|
|
|
|
|
|
|
0x042e => 'wen' , # # !!! 3 letters |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
0x040a => 'es-es', # |
135
|
|
|
|
|
|
|
0x080a => 'es-mx', # |
136
|
|
|
|
|
|
|
0x0c0a => 'es-es', # |
137
|
|
|
|
|
|
|
0x100a => 'es-gt', # |
138
|
|
|
|
|
|
|
0x140a => 'es-cr', # |
139
|
|
|
|
|
|
|
0x180a => 'es-pa', # |
140
|
|
|
|
|
|
|
0x1c0a => 'es-do', # |
141
|
|
|
|
|
|
|
0x200a => 'es-ve', # |
142
|
|
|
|
|
|
|
0x240a => 'es-co', # |
143
|
|
|
|
|
|
|
0x280a => 'es-pe', # |
144
|
|
|
|
|
|
|
0x2c0a => 'es-ar', # |
145
|
|
|
|
|
|
|
0x300a => 'es-ec', # |
146
|
|
|
|
|
|
|
0x340a => 'es-cl', # |
147
|
|
|
|
|
|
|
0x380a => 'es-uy', # |
148
|
|
|
|
|
|
|
0x3c0a => 'es-py', # |
149
|
|
|
|
|
|
|
0x400a => 'es-bo', # |
150
|
|
|
|
|
|
|
0x440a => 'es-sv', # |
151
|
|
|
|
|
|
|
0x480a => 'es-hn', # |
152
|
|
|
|
|
|
|
0x4c0a => 'es-ni', # |
153
|
|
|
|
|
|
|
0x500a => 'es-pr', # |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
0x0430 => 'st' , # == soto, sesotho |
156
|
|
|
|
|
|
|
0x0441 => 'sw-ke', # |
157
|
|
|
|
|
|
|
0x041D => 'sv' , # |
158
|
|
|
|
|
|
|
0x081d => 'sv-fi', # |
159
|
|
|
|
|
|
|
0x0449 => 'ta' , # |
160
|
|
|
|
|
|
|
0x0444 => 'tt' , # |
161
|
|
|
|
|
|
|
0x044a => 'te' , # |
162
|
|
|
|
|
|
|
0x041E => 'th' , # |
163
|
|
|
|
|
|
|
0x0431 => 'ts' , # (not Tonga!) |
164
|
|
|
|
|
|
|
0x0432 => 'tn' , # == Setswana |
165
|
|
|
|
|
|
|
0x041f => 'tr' , # |
166
|
|
|
|
|
|
|
0x0422 => 'uk' , # |
167
|
|
|
|
|
|
|
0x0420 => 'ur-pk', # |
168
|
|
|
|
|
|
|
0x0820 => 'ur-in', # |
169
|
|
|
|
|
|
|
0x0443 => 'uz-latn', # |
170
|
|
|
|
|
|
|
0x0843 => 'uz-cyrl', # |
171
|
|
|
|
|
|
|
0x0433 => 'ven' , # |
172
|
|
|
|
|
|
|
0x042a => 'vi' , # |
173
|
|
|
|
|
|
|
0x0434 => 'xh' , # |
174
|
|
|
|
|
|
|
0x043d => 'yi' , # # formetly ji |
175
|
|
|
|
|
|
|
0x0435 => 'zu' , # |
176
|
|
|
|
|
|
|
); |
177
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub get_ms_locale { |
180
|
1
|
|
|
1
|
1
|
47
|
my $locale; |
181
|
1
|
50
|
|
|
|
2
|
return unless defined do { |
182
|
|
|
|
|
|
|
# see if there's a W32 registry on this machine, and if so, look in it |
183
|
1
|
|
|
|
|
8
|
local $SIG{"__DIE__"} = ""; |
184
|
1
|
|
|
1
|
|
489
|
eval ' |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
78
|
|
185
|
|
|
|
|
|
|
use Win32::TieRegistry (); |
186
|
|
|
|
|
|
|
my $i18n = Win32::TieRegistry->new( |
187
|
|
|
|
|
|
|
"HKEY_CURRENT_USER/Control Panel/International", |
188
|
|
|
|
|
|
|
{ Delimiter => "/" } |
189
|
|
|
|
|
|
|
); |
190
|
|
|
|
|
|
|
#print "no key!" unless $i18n; |
191
|
|
|
|
|
|
|
$locale = $i18n->GetValue("Locale") if $i18n; |
192
|
|
|
|
|
|
|
undef $i18n; |
193
|
|
|
|
|
|
|
'; |
194
|
|
|
|
|
|
|
#print "<$@>\n" if $@; |
195
|
1
|
|
|
|
|
10
|
$locale; |
196
|
|
|
|
|
|
|
}; |
197
|
0
|
0
|
|
|
|
|
return unless $locale =~ m/^[0-9a-fA-F]+$/s; |
198
|
0
|
|
|
|
|
|
return hex($locale); |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
sub get_language { |
202
|
0
|
|
0
|
0
|
1
|
|
my $lang = $MSLocale2LangTag{ $_[0] || get_ms_locale() || '' }; |
|
|
|
0
|
|
|
|
|
203
|
0
|
0
|
|
|
|
|
return unless $lang; |
204
|
0
|
|
|
|
|
|
return $lang; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub get_locale { |
208
|
|
|
|
|
|
|
# I guess this is right. |
209
|
0
|
|
|
0
|
1
|
|
my $lang = get_language(@_); |
210
|
0
|
0
|
0
|
|
|
|
return unless $lang and $lang =~ m/^[a-z]{2}(?:-[a-z]{2})?$/s; |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
# should we try to turn "fi" into "fi_FI"? |
213
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
$lang =~ tr/-/_/; |
215
|
0
|
|
|
|
|
|
return $lang; |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
# If we're just executed... |
220
|
|
|
|
|
|
|
unless(caller) { |
221
|
|
|
|
|
|
|
my $locale = get_ms_locale(); |
222
|
|
|
|
|
|
|
if($locale) { |
223
|
|
|
|
|
|
|
printf "Locale 0x%08x (%s => %s) => Lang %s\n", |
224
|
|
|
|
|
|
|
$locale, $locale, |
225
|
|
|
|
|
|
|
get_locale($locale) || '?', |
226
|
|
|
|
|
|
|
get_language($locale) || '?', |
227
|
|
|
|
|
|
|
} else { |
228
|
|
|
|
|
|
|
print "Can't get ms-locale\n"; |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
233
|
|
|
|
|
|
|
1; |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
__END__ |