diff --git a/.github/workflows/translations.yml b/.github/workflows/translations.yml new file mode 100644 index 0000000000000000000000000000000000000000..4683cee7e642f3f02dcdb2604faaafd49a50020e --- /dev/null +++ b/.github/workflows/translations.yml @@ -0,0 +1,18 @@ +name: XML Translations Check + +on: + pull_request: + branches: [master] + paths: ['src/RealTime/Localization/Translations/**'] + +jobs: + check-xml: + name: Check XML localization files + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v1 + + - name: Validate XML files + run: ./env/xmltools.ps1 ./src/RealTime/Localization/Translations diff --git a/env/xmltools.ps1 b/env/xmltools.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..b40fff4277d34145672271d278d13c24ea63e775 --- /dev/null +++ b/env/xmltools.ps1 @@ -0,0 +1,50 @@ +function Test-XmlFile { + + [CmdletBinding()] + param ( + [parameter(mandatory=$true)][ValidateNotNullorEmpty()][string]$xmlFilePath + ) + + $xml = New-Object System.Xml.XmlDocument + try { + $xml.Load((Get-ChildItem -Path $xmlFilePath).FullName) + Write-Host "XML file is valid: $xmlFilePath" + return $true + } + catch [System.Xml.XmlException] { + Write-Error "XML file is invalid: $xmlFilePath --> $($_.toString())" + return $false + } +} + +function Test-XmlFiles { + + [CmdletBinding()] + param ( + [parameter(mandatory=$true)][ValidateNotNullorEmpty()][string]$filesPath + ) + + if (!(Test-Path -Path $filesPath)){ + throw "$filesPath is not valid. Please provide a valid path" + } + + $files = Get-ChildItem -Path $filesPath -Recurse -Include *.xml + $result = $true + + foreach ($f in $files) { + $fileResult = Test-XmlFile $f.FullName + if (!$fileResult) { + $result = $false + } + } + + return $result +} + +$scriptResult = Test-XmlFiles $args[0] +if ($scriptResult) { + exit 0 +} +else { + exit 1 +} \ No newline at end of file