forked from OpenRCT2/Localisation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.ps1
88 lines (78 loc) · 2.09 KB
/
check.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
# Run langcheck on all language files
[CmdletBinding()]
param (
[Parameter(Mandatory = $false)]
[switch]$Rebuild = $false
)
$ErrorActionPreference = "Stop"
# Build langcheck
$langcheckPath = ".\langcheck\bin\Release\netcoreapp1.1\langcheck.dll"
if (-not (Test-Path -PathType Leaf $langcheckPath) -or $Rebuild)
{
pushd ".\langcheck"
dotnet restore -v m
dotnet build -c Release
popd
}
# Grab en-GB from main repository
$languagePath = ".\data\language"
$basePack = "$languagePath\en-GB.txt"
if (-not (Test-Path -PathType Leaf $basePack))
{
$url = "https://raw.githubusercontent.com/OpenRCT2/OpenRCT2/develop/data/language/en-GB.txt"
Invoke-WebRequest $url -OutFile $basePack
}
$languageFiles = Get-ChildItem $languagePath
$result = $true
# Check en-GB for errors
dotnet $langcheckPath $basePack $translationPack
if ($LASTEXITCODE -ne 0)
{
$result = $false
}
# Check all language files against en-GB
foreach ($languageFile in $languageFiles)
{
if ($languageFile.Name -eq "en-GB.txt")
{
continue;
}
$translationPack = "$languagePath\$($languageFile.Name)"
$sw = [Diagnostics.Stopwatch]::StartNew()
dotnet $langcheckPath $basePack $translationPack | ForEach-Object {
if ($env:APPVEYOR -and $_.StartsWith(" info: "))
{
$message = $($languageFile.BaseName) + ": " + $_.Substring(8)
Add-AppveyorMessage $message
}
$_
}
$sw.Stop()
$testDuration = $sw.ElapsedMilliseconds
if ($LASTEXITCODE -ne 0)
{
if ($env:APPVEYOR)
{
$testName = $languageFile.Name
Add-AppveyorTest $testName -Outcome Failed -Duration $testDuration
}
$result = $false
}
else
{
if ($env:APPVEYOR)
{
$testName = $languageFile.Name
Add-AppveyorTest $testName -Outcome Passed -Duration $testDuration
}
}
}
# Exit code
if ($result)
{
exit 0
}
else
{
throw "Some languages contained errors or warnings."
}