-
Notifications
You must be signed in to change notification settings - Fork 1
/
Translation.ps1
50 lines (47 loc) · 1.8 KB
/
Translation.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
Push-Location "C:\Program Files (x86)\Steam\steamapps\common\SpaceEngineers\Content\Data"
$FilesWithItems = Get-ChildItem -File | Where-Object -Property BaseName -NotLike 'Blueprint*' | Select-String -SimpleMatch "DisplayName_Item" -List | Select-Object -ExpandProperty Filename
$Localization = @{}
Select-Xml -Path .\Localization\MyTexts.resx -XPath "root/data" | Select-Object -ExpandProperty Node | ForEach-Object {$Localization[$_.name] = $_.value}
#Select-Xml -Path .\Localization\MyTexts.da.resx -XPath "root/data" | Select-Object -ExpandProperty Node | Where-Object {$_.value -ne $null} | ForEach-Object {$Localization[$_.name] = $_.value}
function Get-ItemsFromSBC {
param (
$SBCFile
)
$BaseName = Get-ChildItem $SBCFile | Select-Object -ExpandProperty Basename
Select-Xml -Path $SBCFile -XPath ('Definitions',$BaseName,($BaseName.SubString(0,$BaseName.Length - 1)) -Join '/') |
Select-Object -ExpandProperty Node |
Select-Object @{
Name='TypeId'
Expression={
$_.Id.TypeID
}
}, `
@{
Name='SubtypeId'
Expression={
$_.Id.SubtypeID
}
}, `
@{
Name='TypeDef'
Expression={
$_.Id.TypeID,$_.Id.SubTypeID -Join '/'
}
}, `
DisplayName,
@{
Name='Localized'
Expression={
$Localization[$_.DisplayName]
}
}
}
Write-Host '[Translation]'
foreach($File in $FilesWithItems) {
Get-ItemsFromSBC $File |
Where-Object {$_.TypeId -ne 'TreeObject'} |
Select-Object @{Name='Translation';expression={"$($_.TypeDef)=$($_.Localized)"}} |
Select-Object -ExpandProperty Translation |
Write-Host
}
Pop-Location