-
Notifications
You must be signed in to change notification settings - Fork 1
/
DeployWiz_LanguageUI.vbs
executable file
·548 lines (376 loc) · 14.4 KB
/
DeployWiz_LanguageUI.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
' // ***************************************************************************
' //
' // Copyright (c) Microsoft Corporation. All rights reserved.
' //
' // Microsoft Deployment Toolkit Solution Accelerator
' //
' // File: DeployWiz_LanguageUI.vbs
' //
' // Version: 6.3.8330.1000
' //
' // Purpose: Script methods used for the language UI (locale, timezone) pane
' //
' // ***************************************************************************
Option Explicit
dim g_oXMLLanguageList
Function oXMLLanguageList
If IsEmpty(g_oXMLLanguageList) then
Set g_oXMLLanguageList = oUtility.LoadConfigFileSafe( "scripts\ListOfLanguages.xml" )
End if
Set oXMLLanguageList = g_oXMLLanguageList
End function
dim g_oPackageGroup
''''''''''''''''''''''''''''''''''''''
function AddLanguage( LanugageToAdd )
Dim oLang, oOption2, sLangToAdd
' sLangToAdd = GetParentLanguageFromLocale(LanugageToAdd)
sLangToAdd = LanugageToAdd
For each oLang in oXMLLanguageList.selectNodes("//LOCALEDATA/LOCALE[IFLAGS='1' and SNAME]")
If ucase(oUtility.SelectSingleNodeString(oLang,"SNAME")) = ucase(LanugageToAdd) then
Set oOption2 = document.createElement("OPTION")
oOption2.Text = oUtility.SelectSingleNodeString(oLang,"SENGDISPLAYNAME")
If not oLang.SelectSingleNode("SNAME") is nothing then
oOption2.Value = lcase(oUtility.SelectSingleNodeString(oLang,"SNAME"))
UILanguage.add oOption2
End if
Exit for
End if
Next
End function
Function Locale_Initialization
Dim oItem
Dim oXMLPackageList
Dim FoundLocale
Dim AllreadyAddedLanguages
Dim aLangPack
Dim oOption2
Dim thisLocale
' g_sPackageDialogBox = ""
oLogging.CreateEntry "###### Locale_Initialization ###### " , LogTypeInfo
' Disable fields as appropriate
If UCase(oEnvironment.item("SkipLocaleSelection")) = "YES" then
UILanguage.Disabled = true
UserLocale_Edit.Disabled = true
KeyboardLocale_Edit.Disabled = true
ElseIf Left(oEnvironment.Item("ImageBuild"), 1) = "5" then
UILanguage.Disabled = true
End if
' Add a Language for each package selected
set oXMLPackageList = new ConfigFile
oXMLPackageList.sFileType = "Packages"
If IsInstallationUltimateEnterprise then
' Add langauges allready installed on the image.
AllreadyAddedLanguages = ""
For each oItem in oEnvironment.ListItem("ImageLanguage").Keys
If oItem <> "" then
AddLanguage oItem
AllreadyAddedLanguages = AllreadyAddedLanguages & vbTab & oItem
End if
Next
End if
aLangPack = property("LanguagePacks")
If not isArray(aLangPack) then
' Force LanguagePacks variable as an array for non Ultimate/Enterprise builds.
aLangPack = array(aLangPack)
oProperties.Item("LanguagePacks") = aLangPack
End if
For each oItem in aLangPack
FoundLocale = ""
If oItem = "DEFAULT" then
' Skip...
ElseIf not oXMLPackageList is nothing then
If oXMLPackageList.FindAllItems.Exists(oItem) then
FoundLocale = oUtility.SelectSingleNodeString(oXMLPackageList.FindAllItems.Item(oItem),"./Language")
End if
End if
If FoundLocale <> "" and Instr(1,AllreadyAddedLanguages, FoundLocale, vbTextCompare ) = 0 then
AddLanguage FoundLocale
AllreadyAddedLanguages = AllreadyAddedLanguages & vbTab & FoundLocale
End if
Next
If AllreadyAddedLanguages = "" then
For each oItem in oEnvironment.ListItem("ImageLanguage").Keys
If oItem <> "" then
AddLanguage oItem
AllreadyAddedLanguages = AllreadyAddedLanguages & vbTab & oItem
End if
Next
End if
ForceLCase "UILanguage"
ForceLCase "UserLocale"
ForceLCase "KeyboardLocale"
oLogging.CreateEntry "Languages Displayed: " & AllreadyAddedLanguages , LogTypeInfo
oLogging.CreateEntry "UILanguage: " & property("UILanguage") , LogTypeVerbose
' Populate the Locale
For each oItem in oXMLLanguageList.selectNodes("//LOCALEDATA/LOCALE[IFLAGS='1']")
Set oOption2 = document.createElement("OPTION")
oOption2.Text = oUtility.SelectSingleNodeString(oItem,"SENGDISPLAYNAME")
oOption2.Value = lcase(oUtility.SelectSingleNodeString(oItem,"./SNAME") & ";" & oUtility.SelectSingleNodeString(oItem,"ILANGUAGE"))
UserLocale_Edit.add oOption2
Next
PopulateElements
' Get default Language and populate
If UILanguage.Value <> "" then
thisLocale = UILanguage.Value
Elseif Property("UILanguage") <> "" then
thisLocale = Property("UILanguage")
ElseIf oEnvironment.Item("ImageLanguage001") <> "" then
thisLocale = oEnvironment.Item("ImageLanguage001")
Else
thisLocale = GetDefaultInstallationLocaleString
End if
If IsEmpty(thisLocale) then
thisLocale = "en-US" ' WinPE *may* not have the locale defined
End if
SetNewLanguageEx thisLocale
SetNewLocaleEx thisLocale
End function
Function ForceLCase( sPropertyName )
If Property(sPropertyName) <> lcase(Property(sPropertyName)) then
If oProperties.Exists(sPropertyName) then
oProperties.Item(sPropertyName) = lcase(oProperties.Item(sPropertyName))
Else
oProperties.Add sPropertyName, lcase(Property(sPropertyName))
End if
End if
End function
Function SetNewLanguage
If oProperties.exists("UserLocale") then
oProperties.remove "UserLocale"
End if
SetNewLanguageEx UILanguage.Value
SetNewLocale
End Function
Function SetNewLocale
If instr(1,UserLocale_Edit.Value,";",vbTextCompare) <> 0 then
If oProperties.exists("KeyboardLocale") then
oProperties.remove "KeyboardLocale"
End if
SetNewLocaleEx mid(UserLocale_Edit.Value,1,instr(1,UserLocale_Edit.Value,";",vbTextCompare) - 1)
End if
End Function
Function SetNewLanguageEx( thisLocale )
Dim LCID
oLogging.CreateEntry "SetNewLanguageEx " & thisLocale, LogTypeVerbose
' Get the default UserLocale
If Property("UserLocale") <> "" then
UserLocale_Edit.Value = lcase(Property("UserLocale") & ";" & GetLCIDFromSName( Property("UserLocale") ))
ElseIf instr(1,Property("KeyboardLocale"),":",vbTextCompare) <> 0 and len(trim(Property("KeyboardLocale"))) = len("0000:12345678") then
LCID = left(Property("KeyboardLocale"),instr(1,Property("KeyboardLocale"),":",vbTextCompare)-1)
UserLocale_Edit.Value = lcase(GetSNameFromLCID(LCID) & ";" & LCID)
Else
UserLocale_Edit.Value = lcase(thisLocale & ";" & GetLCIDFromSName( thisLocale ))
End if
oLogging.CreateEntry "UserLocale : " & Property("UserLocale") & " - " & UserLocale_Edit.Value, LogTypeVerbose
If Property("ImageLanguage001") = "" then
oProperties.Add "ImageLanguage001", thisLocale
End if
End function
Function SetNewLocaleEx (thisLocale)
Dim sKeyboard
Dim sItem
Dim sNew
oLogging.CreateEntry "SetNewLocaleEx " & thisLocale & " - " & Property("KeyboardLocale"), LogTypeVerbose
' Set the default Keyboard
sNew = ""
If Property("KeyboardLocale") <> "" then
sKeyboard = Property("KeyboardLocale")
If instr(1,sKeyboard,";",vbTExtCompare) <> 0 then
' Use the 1st instance of a ; delimited array that contains a :
for each sItem in split(sKeyboard,";")
If instr(1,sItem,":",vbTextCompare) <> 0 then
sKeyboard = trim(sItem)
exit for
End if
next
If isempty(sKeyboard) then
sKeyboard = trim(left(sKeyboard,instr(1,sKeyboard,";",vbTExtCompare)-1))
End if
End if
If instr(1,sKeyboard,":",vbTextCompare) <> 0 and len(sKeyboard) = len("0000:12345678") then
' KeyboardLocale appears to be in the format 0409:00000409 format
sNew = mid(sKeyboard,instr(1,sKeyboard,":",vbTextCompare)+1)
ElseIf instr(1,sKeyboard,"-",vbTextCompare) <> 0 Then
sNew = right("00000000" & GetLCIDFromSName(sKeyboard),8)
End if
End if
If sNew = "" Then
sNew = right("00000000" & GetKeyboardFromSName(thisLocale),8)
End if
KeyboardLocale_Edit.Value = lcase(sNew)
If KeyboardLocale_Edit.Value = "" then
KeyboardLocale_Edit.Value = "00000409"
End if
oLogging.CreateEntry "KeyboardLocale: " & Property("KeyboardLocale") & " - " & KeyboardLocale_Edit.Value & " - " & sNew, LogTypeVerbose
End function
''''''''''''''''''''''''''''''''
Function GetDefaultInstallationLocaleString
Dim oItem
' First see if a UserLocal value was specified
If Property("UserLocale") <> "" then
Set oItem = oXMLLanguageList.SelectSingleNode("//LOCALEDATA/LOCALE[@ID = '" & lcase(Property("UserLocale")) & "']/SNAME")
If not oItem is nothing then
GetDefaultInstallationLocaleString = oItem.Text
Exit Function
End if
End if
' No, so get the default locale
Set oItem = oXMLLanguageList.SelectSingleNode("//LOCALEDATA/LOCALE[@ID = '" & lcase(right("0000" & hex(GetLocale),4)) & "']/SNAME")
If not oItem is nothing then
GetDefaultInstallationLocaleString = oItem.Text
End if
End function
Function GetDefaultInstallationLanguageString
GetDefaultInstallationLanguageString = GetParentLanguageFromLocale(GetDefaultInstallationLocaleString)
End function
Function GetParentLanguageFromLocale( Locale)
Dim oLocale
For each oLocale in oXMLLanguageList.selectNodes("//LOCALEDATA/LOCALE/SNAME")
If UCase(Locale) = UCase(oLocale.text) then
GetParentLanguageFromLocale = oUtility.SelectSingleNodeString(oLocale.ParentNode,"SISO639LANGNAME")
Exit for
End if
Next
End function
Function GetSNameFromLCID ( LCID )
GetSNameFromLCID = oUtility.SelectSingleNodeString(oXMLLanguageList,"/LOCALEDATA/LOCALE[@ID='" & lcase(LCID) & "']/SNAME")
End function
Function GetKeyboardFromSName ( sName )
Dim oLocale
For each oLocale in oXMLLanguageList.selectNodes("//LOCALEDATA/LOCALE/SNAME")
If UCase(sName) = UCase(oLocale.text) then
GetKeyboardFromSName = oUtility.SelectSingleNodeString(oLocale.ParentNode,"DEFAULTKEYBOARD")
Exit for
End if
Next
End Function
Function GetLCIDFromSName ( sName )
Dim oLocale
For each oLocale in oXMLLanguageList.selectNodes("//LOCALEDATA/LOCALE/SNAME")
If UCase(sName) = UCase(oLocale.text) then
GetLCIDFromSName = oUtility.SelectSingleNodeString(oLocale.ParentNode,"ILANGUAGE")
Exit for
End if
Next
End Function
''''''''''''''''''''''''''''''''
Function IsInstallationUltimateEnterprise
IsInstallationUltimateEnterprise = oUtility.IsHighEndSKUEx( oEnvironment.Item("ImageFlags") )
End function
'''''''''''''''''''''''''''''''''''''
' Validate LanguagePack
'
''''''''''''''''''''''''''''''''''''''
Function Locale_Validation
Dim iSplit
Locale_Validation = TRUE
If not UILanguage.Disabled then
UILanguage_err.style.display = "none"
If UILanguage.SelectedIndex = -1 then
UILanguage_Err.style.display = "inline"
Locale_Validation = FALSE
End if
End if
If not UserLocale_Edit.Disabled then
UserLocale_Err.style.display = "none"
If UserLocale_Edit.SelectedIndex = -1 then
UserLocale_Err.style.display = "inline"
Locale_Validation = FALSE
End if
End if
If not KeyboardLocale_Edit.Disabled then
KeyboardLocale_Err.style.display = "none"
If KeyboardLocale_Edit.SelectedIndex = -1 then
KeyboardLocale_Err.style.display = "inline"
Locale_Validation = FALSE
End if
End if
If not Locale_Validation then
Exit Function
End if
iSplit = instr(1,UserLocale_Edit.Value,";",vbTextCompare)
TestAndLog iSplit <> 0 , "Verify UserLocale_Edit contains Comma Delimiter: " & UserLocale_Edit.Value
If instr(1,UserLocale_Edit.Value,";",vbTextCompare) <> 0 then
' Take the LCID From UserLocale and add it to the KeyboardLocale
KeyboardLocale.Value = UserLocale_Edit.Value & ":" & KeyboardLocale_Edit.Value
Else
' Some kind of Error
KeyboardLocale.Value = right("0000" & hex(GetLocale),4) & ":" & KeyboardLocale_Edit.Value
End if
If iSplit <> 0 then
UserLocale.Value = mid(UserLocale_Edit.Value,1,instr(1,UserLocale_Edit.Value,";",vbTextCompare) - 1)
Else
UserLocale.Value = UserLocale_Edit.Value
End if
End function
'''''''''''''''''''''''''''''''''''''
' Timezone functions
'
'''''''''''''''''''''''''''''''''''''
Function SetTimeZoneValue
' When the user selects a value in the TimeZoneList we must populate the hidden Text Values
TimeZoneName.Value = TimeZoneList.value
End function
Function TimeZone_Initialization
Dim TimeZone, i, TimeSplit, Item, test
' Disable fields as appropriate
If UCase(oEnvironment.item("SkipTimeZone")) = "YES" then
TimeZoneList.Disabled = true
End if
' If TimeZone Property is set, then select the coresponding list item.
If Property("TimeZoneName") <> "" then
For i = 0 to TimeZoneList.Options.Length - 1
If UCase(Property("TimeZoneName")) = UCase(TimeZoneList.Options(i).value) then
TimeZoneList.SelectedIndex = i
TimeZoneName.Value = TimeZoneList.Options(i).value
Exit function
End if
Next
End if
' Extract out the current TimeZone
For each TimeZone in objWMI.InstancesOf("Win32_TimeZone")
Exit for ' Take the first entry and break out of loop
Next
If IsEmpty(TimeZone) then
Exit function
End if
'Try to match the timezone against the current Timezone Name
For i = 0 to TimeZoneList.Options.Length - 1
If UCase(TimeZoneList.Options(i).Text) = UCase(TimeZone.Description) then
TimeZoneList.SelectedIndex = i
TimeZoneName.Value = TimeZoneList.Options(i).value
Exit function
End if
' See if there is a match in the alternate description or other Values
For each test in array(TimeZone.Description,TimeZone.StandardName)
If test <> "" then
If UCase(test) = UCase(TimeZoneList.Options(i).value) then
TimeZoneList.SelectedIndex = i
TimeZoneName.Value = TimeZoneList.Options(i).value
Exit function
End if
End if
Next
Next
' Try to match against the closest GMT value (This *May* select an entry that is not *exact*)
For i = 0 to TimeZoneList.Options.Length - 1
test = Instr(1, TimeZone.Description," ")
If test <> 0 then
If left(TimeZone.Description, test) = left(TimeZoneList.Options(i).Text, test) then
TimeZoneList.SelectedIndex = i
TimeZoneName.Value = TimeZoneList.Options(i).value
Exit function
End if
End if
Next
End function
Function TimeZone_Validation
' Return true if disabled or if a value has been specified
If UCase(oEnvironment.item("SkipTimeZone")) = "YES" then
TimeZone_Validation = True
Elseif TimeZoneName.Value <> "" then
TimeZone_Validation = True
Else
TimeZone_Validation = False
End if
End function