-
Notifications
You must be signed in to change notification settings - Fork 0
/
Update-GameData.ps1
687 lines (595 loc) · 24.6 KB
/
Update-GameData.ps1
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
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
# We're grabbing official language list from an enum here
using module ./lib/EXHF.psm1
[CmdletBinding()]
param (
# Output file type (Required)
# Check out help message in ConvertFrom-GameData.ps1
[Parameter(Mandatory)]
[string]
$FileType,
# Game version to update from
# Notes:
# * 'Game version' is just a name of the folder
# with the necessary game files.
# * It can't be 'latest'
[Parameter(Mandatory)]
[string]
$CurrentVersion,
# Game version to update to (Default: latest)
# Default 'latest' takes the last folder in dump directory.
# Otherwise specify the _name of the folder_ that you want
# to dump from.
[Parameter()]
[string]
$NewVersion = 'latest',
# Do not perform actual update (Default: No)
# Enabling this ensures that no strings files are touched.
# The script will only output what is about to be done.
# Verbose will be enabled in this case.
# Note: Changelogs will still be exported at the end.
[Parameter()]
[switch]
$DryRun = $false,
# Compress strings files (Default: No)
# Some file formats like XLIFF may allow compressing
# by dropping all whitespace except the one in strings.
# This switch has no effect on file types without
# compression support.
[Parameter()]
[switch]
$Compress = $false
)
function Compare-Files {
param (
# First file path
[Parameter(Mandatory)]
[string]
$File1,
# Second file path
[Parameter(Mandatory)]
[string]
$File2
)
if ((Test-Path -Path $File1) -and -not (Test-Path -Path $File2)) {
return $COMPARISON_ONLY_FILE1_EXISTS
}
if (-not (Test-Path -Path $File1) -and (Test-Path -Path $File2)) {
return $COMPARISON_ONLY_FILE2_EXISTS
}
if ( -not ((Test-Path $File1) -and (Test-Path $File2)) ) {
return $COMPARISON_FILES_DONT_EXIST
}
$hash1 = $(Get-FileHash $File1).hash
$hash2 = $(Get-FileHash $File2).hash
if ($hash1 -eq $hash2) {
return $COMPARISON_FILES_SAME
} else {
return $COMPARISON_FILES_DIFFERENT
}
}
function Join-WeblateUrl {
param (
[Parameter()]
[string]
$BaseUrl = $WEBLATE.URI,
[Parameter()]
[string]
$ProjectSlug = $WEBLATE.PROJECT_SLUG,
[Parameter(Mandatory)]
[string]
$ComponentGamePath,
[Parameter(Mandatory)]
[string]
$Language,
[Parameter(Mandatory)]
[int]
$StringId
)
$ComponentSlug = $ComponentGamePath.ToLower() -creplace '^exd/','' -creplace '/','-'
return "https://{0}/translate/{1}/{2}/{3}/?q=context%3Ar`"%2F%2F%2F{4}%24`"" -f $BaseUrl, $ProjectSlug, $ComponentSlug, $Language, $StringId
}
function Update-StringsOfficial {
param (
[Parameter(Mandatory)]
[System.Collections.Generic.SortedDictionary[int,pscustomobject]]
$TableCurrent,
[Parameter(Mandatory)]
[System.Collections.Generic.SortedDictionary[int,pscustomobject]]
$TableNew,
[Parameter(Mandatory)]
[string]
$FileName,
[Parameter()]
[switch]
$AddStringIDs = $false
)
$changelog = [System.Collections.Generic.List[pscustomobject]]::new()
# Step 1. Uniquely collect all indexes from both tables
$indexes_current = [int[]] $TableCurrent.Keys
$indexes_new = [int[]] $TableNew.Keys
$indexes_all = $indexes_current + $indexes_new | Sort-Object -Unique
# Step 2. Main thing
foreach ($index in $indexes_all) {
# Removed string
if (-not $TableNew.ContainsKey($index)) {
$changelog.Add([pscustomobject]@{
File = $FileName
Index = $index
Url = ''
Old = $TableCurrent[$index].String
New = '[Removed]'
})
$result_ok = $TableCurrent.Remove($index)
if (-not $result_ok) {
throw "Error removing a row from the table."
}
continue
}
if ($AddStringIDs) {
$new_string = "{0}_{1}" -f $index, $TableNew[$index].String
} else {
$new_string = $TableNew[$index].String
}
# New string
if (-not $TableCurrent.ContainsKey($index)) {
$TableCurrent.Add($index, [pscustomobject]@{
String = $new_string
State = $STRING_STATE_APPROVED
})
$changelog.Add([pscustomobject]@{
File = $FileName
Index = $index
Url = Join-WeblateUrl -ComponentGamePath $game_path -Language $lang -StringId $index
Old = '[N/A]'
New = $new_string
})
continue
}
# Same string
if ($TableNew[$index].String -ceq $TableCurrent[$index].String) {
continue
}
# Changed string
$changelog.Add([pscustomobject]@{
File = $FileName
Index = $index
Url = Join-WeblateUrl -ComponentGamePath $game_path -Language $lang -StringId $index
Old = $TableCurrent[$index].String
New = $new_string
})
$TableCurrent[$index].String = $new_string
continue
}
return ,$changelog
}
function Update-StringsUnofficial {
param (
[Parameter(Mandatory)]
[System.Collections.Generic.SortedDictionary[int,pscustomobject]]
$TableCurrent,
[Parameter(Mandatory)]
[System.Collections.Generic.List[pscustomobject]]
$ChangesOfficial,
[Parameter(Mandatory)]
[string]
$FileName,
[Parameter()]
[switch]
$AddStringIDs = $false
)
$changelog = [System.Collections.Generic.List[pscustomobject]]::new()
foreach ($change in $ChangesOfficial) {
$index = $change.Index
if ($AddStringIDs) {
$new_string = "{0}_{1}" -f $index, $change.New
} else {
$new_string = ''
}
# New string
if ($change.Old -eq '[N/A]') {
$changelog.Add([pscustomobject]@{
File = $FileName
Index = $index
Url = Join-WeblateUrl -ComponentGamePath $game_path -Language $lang_un -StringId $index
'Old Source' = $change.Old
'New Source' = $change.New
'Old Translation' = '[N/A]'
})
# Remove 'if' statement if your translation tool requires target string to exist
if ($AddStringIDs) {
$TableCurrent.Add($index, [pscustomobject]@{
String = $new_string
State = $STRING_STATE_NOT_TRANSLATED
})
}
continue
}
# Removed string
if ($change.New -eq '[Removed]') {
$changelog.Add([pscustomobject]@{
File = $FileName
Index = $index
Url = ''
'Old Source' = $change.Old
'New Source' = $change.New
'Old Translation' = $TableCurrent[$index].String
})
$null = $TableCurrent.Remove($index)
continue
}
# Changed translated string
if ($TableCurrent.ContainsKey($index) -and $TableCurrent[$index].String) {
$changelog.Add([pscustomobject]@{
File = $FileName
Index = $index
Url = Join-WeblateUrl -ComponentGamePath $game_path -Language $lang_un -StringId $index
'Old Source' = $change.Old
'New Source' = $change.New
'Old Translation' = $TableCurrent[$index].String
})
$TableCurrent[$index].String = $new_string
$TableCurrent[$index].State = $STRING_STATE_NOT_TRANSLATED
continue
}
}
return ,$changelog
}
$LANGUAGES_OFFICIAL = [LanguageCodes].GetEnumNames()
# Start importing stuff
$ErrorActionPreference_before = $ErrorActionPreference
$ErrorActionPreference = 'Stop'
try {
Import-Module -Name "./lib/file_types/$FileType.psm1"
$CONFIG = Import-PowerShellDataFile -Path "./config/config.psd1"
$CONVERSION_LISTS = Import-PowerShellDataFile -Path "./config/conversion_lists.psd1"
$WEBLATE = Import-PowerShellDataFile -Path "./config/weblate.psd1"
foreach ($path_name in [string[]] $CONFIG.PATHS.Keys) {
try {
$CONFIG.PATHS.$path_name = (Resolve-Path -Path $CONFIG.PATHS.$path_name).Path
}
catch {
Write-Error ("Path {0} could not be resolved." -f $CONFIG.PATHS.$path_name)
return 2
}
}
}
catch {
$ErrorActionPreference = $ErrorActionPreference_before
$_
return 2
}
$ErrorActionPreference = $ErrorActionPreference_before
# Finish importing stuff
$InformationPreference = 'Continue'
if ($CONFIG.VERBOSE) {
$VerbosePreference = 'Continue'
} else {
$VerbosePreference = 'SilentlyContinue'
}
if ($CurrentVersion -eq 'latest') {
Write-Error "Current version can't be 'latest'"
return 2
} else {
$dump_dir_current = "{0}/{1}" -f $CONFIG.PATHS.DUMP_DIR, $CurrentVersion
if (-not $(Test-Path -Path $dump_dir_current)) {
throw "Version $CurrentVersion was not found in dump folder."
}
}
Write-Information "Current version path: $dump_dir_current"
if ($NewVersion -eq 'latest') {
$version_list = Get-ChildItem -Path $CONFIG.PATHS.DUMP_DIR -Directory
$dump_dir_new = $version_list[-1]
$version_regex = '\d{4}\.\d{2}\.\d{2}\.\d{4}\.\d{4}'
$found = $dump_dir_new.FullName -match $version_regex
if ($found) {
if ($Matches.Count -ne 1) {
Write-Error "Parsed more than one version numbers from the following path:"
Write-Error " $dump_dir_new"
Write-Error "Please specify the new version explicitly."
throw
}
$NewVersion = $Matches[0]
} else {
throw "Couldn't parse latest version number"
}
} else {
$dump_dir_new = "{0}/{1}" -f $CONFIG.PATHS.DUMP_DIR, $NewVersion
if (-not $(Test-Path -Path $dump_dir_new)) {
throw "Version $NewVersion was not found in dump folder."
}
}
Write-Information "New version path: $dump_dir_new"
# Make a normal array of all split files
$split_files = foreach ($split_file in $CONVERSION_LISTS.SPLIT_FILES.GetEnumerator()) {
foreach ($file_name in [string[]] $split_file.Value.Keys) {
$file_name
}
}
Write-Information "Getting all new version EXHs..."
$new_exh_list = Get-ChildItem -Path "$dump_dir_new/*.exh" -Recurse -File
Write-Information "Done."
if ($DryRun) {
Write-Information "This is a dry run - no actual changes to the strings files will be made."
}
# This table contains lists that document all of the encountered changes.
# Each of these lists will be exported as a CSV table if they are not
# empty.
# Note that these tables are monolingual. If you want to have a bilingual one
# (probably for unofficial langauges so that you could see what changed
# in the source strings), you'd have to combine them separately. It can
# be done via Combine-Changelogs.ps1 in the `tools` folder.
# [PSCustomObject] structure:
# * File
# * Index
# * Old
# * New
$changelog_tables = @{}
foreach ($lang in $LANGUAGES_OFFICIAL) {
$changelog_tables.$lang = [System.Collections.Generic.List[pscustomobject]]::new()
}
foreach ($new_exh_file in $new_exh_list) {
# Set up readable paths
$file_name = $new_exh_file.BaseName
$sub_path = $new_exh_file.Directory.FullName.Replace("$dump_dir_new/", '') -creplace '/$',''
$current_exh_path = $new_exh_file.FullName.Replace($NewVersion, $CurrentVersion)
$new_exh_path = $new_exh_file.FullName
$game_path = "{0}/{1}" -f $sub_path, $file_name
$strings_dir_path = "{0}/{1}/{2}" -f $CONFIG.PATHS.STRINGS_DIR, $sub_path, $file_name
$log_prefix = "{0}:" -f $game_path
# Skip non-language EXHs right away
$new_exh = [EXHF]::new($new_exh_path)
if ($new_exh.IsLanguageDeclared('none')) {
Write-Verbose "$log_prefix Non-language file, skipping - $new_exh_path"
continue
}
$lang_needs_to_be_updated = @{}
foreach ($lang in $LANGUAGES_OFFICIAL) {
$lang_needs_to_be_updated.$lang = $false
}
$next_file_flag = $false
# Step 1: EXH comparison
switch (Compare-Files -File1 $current_exh_path -File2 $new_exh_path) {
$COMPARISON_FILES_SAME {
# Proceed to EXD checks by doing nothing
Write-Verbose "$log_prefix EXH didn't change - $new_exh_path"
break
}
$COMPARISON_FILES_DIFFERENT {
# Skip EXD checks by flagging all languages for conversion
Write-Information "$log_prefix EXH changed - $new_exh_path"
foreach ($lang in $LANGUAGES_OFFICIAL) {
$lang_needs_to_be_updated.$lang = $true
}
break
}
$global:COMPARISON_ONLY_FILE1_EXISTS {
# Remove associated strings files and proceed to the next EXH
Write-Information "$log_prefix EXH removed - $current_exh_path"
$search_string = "{0}/*.{1}" -f $strings_dir_path, (Get-StringsFileExtension)
$files_to_delete = Get-ChildItem -Path $search_string -File
Write-Verbose "The following strings files will be deleted:"
foreach ($file in $files_to_delete) {
$lang = $file.BaseName
$changelog.$lang.Add([pscustomobject]@{
File = $game_path
Index = ''
Old = ''
New = '[Removed]'
})
Write-Verbose " * $file"
}
if (-not $DryRun) {
$files_to_delete | Remove-Item
}
$next_file_flag = $true
break
}
$COMPARISON_ONLY_FILE2_EXISTS {
# Convert all new files and proceed to the next EXH
Write-Information "$log_prefix New EXH - $new_exh_path"
if (-not $DryRun) {
$result = ./ConvertFrom-GameData.ps1 -ExhPath $new_exh_path `
-FileType $FileType `
-Destination $strings_dir_path
if ($result -eq 2) {
throw "$log_prefix Critical error during conversion"
}
}
foreach ($lang in $LANGUAGES_OFFICIAL) {
$strings_file_path = "{0}/{1}.{2}" -f $strings_dir_path, $lang, (Get-StringsFileExtension)
if (Test-Path -Path $strings_file_path) {
$changelog_tables.$lang.Add([pscustomobject]@{
File = $game_path
Index = ''
Old = ''
New = '[Added]'
})
}
}
$next_file_flag = $true
break
}
$COMPARISON_FILES_DONT_EXIST {
Write-Error "$log_prefix Both EXHs don't exist. This shouldn't happen. Debug info:"
Write-Error "Current EXH path: $current_exh_path"
Write-Error "New EXH path: $new_exh_path"
throw
}
}
if ($next_file_flag) {
continue
}
# Step 2. EXD comparison
# $new_exh was already created before
$current_exh = [EXHF]::new($current_exh_path)
foreach ($lang in $LANGUAGES_OFFICIAL) {
if (-not $new_exh.IsLanguageDeclared($lang)) {
continue
}
$log_prefix_lang = "{0}: ({1})" -f $game_path, $lang.ToUpper()
# Go through EXDs if a language wasn't marked for update earlier
if (-not $lang_needs_to_be_updated.$lang) {
foreach ($page in $new_exh.PageTable.GetEnumerator()) {
$current_exd_path = $current_exh.GetEXDPath($page.Key, $lang)
$new_exd_path = $new_exh.GetEXDPath($page.Key, $lang)
$log_prefix_exd = "{0}: ({1} #{2})" -f $game_path, $lang.ToUpper(), $page.Key
switch (Compare-Files -File1 $current_exd_path -File2 $new_exd_path) {
$COMPARISON_FILES_SAME {
Write-Verbose "$log_prefix_exd EXD page didn't change - $new_exd_path"
break
}
$COMPARISON_FILES_DIFFERENT {
Write-Information "$log_prefix_exd EXD page changed - $new_exd_path"
$lang_needs_to_be_updated.$lang = $true
break
}
$global:COMPARISON_ONLY_FILE1_EXISTS {
Write-Information "$log_prefix_exd EXD page removed - $current_exd_path"
$lang_needs_to_be_updated.$lang = $true
break
}
$COMPARISON_ONLY_FILE2_EXISTS {
Write-Information "$log_prefix_exd EXD page added - $new_exd_path"
$lang_needs_to_be_updated.$lang = $true
break
}
$COMPARISON_FILES_DONT_EXIST {
Write-Warning "$log_prefix_exd Both EXD pages don't exist"
break
}
}
# Whenever there's a change in any of EXDs, quit this loop
# and start updating.
if ($lang_needs_to_be_updated.$lang) {
break
}
}
}
# But if the language is not marked for update even after the loop,
# proceed to the next language.
if (-not $lang_needs_to_be_updated.$lang) {
Write-Information "$log_prefix_lang No changes"
continue
}
# Step 3. Strings file(s) update
# First we deal with the current official language.
# For 'Memory' output type -Destination is not used, but since it's
# required, we're passing some string.
# TODO: Make sense of ParameterSets so that this minor workaround
# wouldn't be required.
# We're also disabling verbosity for these commands,
# otherwise logs would be full of 'Loading module', etc.
# In regards to split file feature:
# * ConvertFrom-GameData with -FileType Memory returns table(s)
# in a hashtable
# * Each key in this hashtable is a file name
# * For split files a key is a split file name
# * For normal files hashtable would have a single entry
# with the normal file name
# * This way the Update script will treat each split file
# as a separate file
$table_current = ./ConvertFrom-GameData.ps1 `
-ExhPath $current_exh_path `
-FileType Memory `
-Languages $lang `
-Destination '.' `
-Verbose:$false
$table_new = ./ConvertFrom-GameData.ps1 `
-ExhPath $new_exh_path `
-FileType Memory `
-Languages $lang `
-Destination '.' `
-Verbose:$false
# Btw we're assuming that both tables will have the same keys
foreach ($table_name in [string[]] $table_current.Keys) {
# Set up some paths again if the file is actually split
if ($table_name -in $split_files) {
$game_path = "{0}/{1}/{2}" -f $sub_path, $file_name, $table_name
$log_prefix_lang = "{0}: ({1})" -f $game_path, $lang.ToUpper()
$strings_dir_path = "{0}/{1}/{2}/{3}" -f $CONFIG.PATHS.STRINGS_DIR, $sub_path, $file_name, $table_name
}
if (-not ($table_current.$table_name.Count -or $table_new.$table_name.Count)) {
Write-Warning "$log_prefix_lang Empty tables, skipping"
continue
}
$changes = Update-StringsOfficial `
-TableCurrent $table_current.$table_name `
-TableNew $table_new.$table_name `
-FileName $table_name
$changelog_tables.$lang.AddRange( $changes )
Write-Information "$log_prefix_lang $($changes.Count) strings changed"
if (-not $DryRun) {
$null = New-Item -Path $strings_dir_path -ItemType Directory -Force -ErrorAction Ignore
$error_code = Export-Strings -Table $table_new.$table_name `
-TargetLanguage $lang `
-Destination $strings_dir_path `
-Compress:$Compress
if ($error_code) {
Write-Error ("$log_prefix Failed to export {0} strings to {1}" -f $lang.ToUpper(), $strings_dir_path)
continue
}
}
# If current language is the main source languaes,
# we also need to update unofficial languages.
# Since we already have a list of changes, we can
# just go through it and apply the same changes
# to unofficial languages.
if ($lang -eq $CONFIG.MAIN_SOURCE_LANGUAGE -and $changes) {
$search_string = "{0}/*.{1}" -f $strings_dir_path, (Get-StringsFileExtension)
if ($DryRun -and -not (Test-Path -Path $search_string)) {
Write-Verbose "$log_prefix_lang Unofficial language scan skipped - strings folder doesn't exist yet"
continue
}
$strings_file_list = Get-ChildItem -Path $search_string -File
foreach ($strings_file in $strings_file_list) {
if ($strings_file.BaseName -in $LANGUAGES_OFFICIAL) {
continue
}
$lang_un = $strings_file.BaseName
Write-Verbose ("$log_prefix Found {0} file at {1}" -f $lang_un.ToUpper(), $strings_file)
if (-not $changelog_tables.$lang_un) {
$changelog_tables.$lang_un = [System.Collections.Generic.List[pscustomobject]]::new()
}
$log_prefix_lang_un = "{0}: ({1})" -f $game_path, $lang_un.ToUpper()
# Remove cache file to force file conversion
$cache_file_path = "{0}/{1}/{2}/{3}.{4}.time" -f `
$CONFIG.PATHS.CACHE_DIR, $game_path, $file_name, $lang_un, (Get-StringsFileExtension)
if (Test-Path -Path $cache_file_path) {
Write-Verbose "$log_prefix_lang_un Removing cache at $cache_file_path"
Remove-Item -Path $cache_file_path -ErrorAction Ignore
}
$table_current_un = Import-Strings -Path $strings_file
$add_string_ids = $file_name -in $CONVERSION_LISTS.ADD_IDS_ON_UPDATE
$changes_un = Update-StringsUnofficial `
-TableCurrent $table_current_un `
-ChangesOfficial $changes `
-FileName $table_name `
-AddStringIDs:$add_string_ids
$changelog_tables.$lang_un.AddRange( $changes_un )
Write-Information "$log_prefix_lang_un $($changes_un.Count) strings changed"
if (-not $DryRun) {
$null = New-Item -Path $strings_dir_path -ItemType Directory -Force -ErrorAction Ignore
$error_code = Export-Strings -Table $table_current_un `
-TargetLanguage $lang_un `
-Destination $strings_dir_path `
-Compress:$Compress
if ($error_code) {
Write-Error "$log_prefix_lang_un Failed to export strings to $strings_dir_path"
continue
}
}
}
}
}
}
}
$GAME_VERSIONS = Get-Content -Path "./versions_list.txt" | ConvertFrom-StringData
foreach ($changelog_table in $changelog_tables.GetEnumerator()) {
if ($changelog_table.Value.Count -gt 0) {
$changelog_dir = "./changelogs/{0}->{1}" -f $GAME_VERSIONS.$CurrentVersion, $GAME_VERSIONS.$NewVersion
$changelog_path = "$changelog_dir/{0}.csv" -f $changelog_table.Key
$null = New-Item -Path $changelog_dir -ItemType Directory -ErrorAction Ignore
$changelog_table.Value | Export-Csv -Path $changelog_path -Encoding utf8NoBOM
Write-Information ("{0} changelog exported to {1}" -f $changelog_table.Key.ToUpper(), $changelog_path)
}
}