Created
November 24, 2019 14:10
-
-
Save freedomcat/8b22dc391613f99f971d32e34111b94e to your computer and use it in GitHub Desktop.
CrowdinXLIFF2txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$inputfile = Get-ChildItem -Filter *.xliff | Where-Object { $_.LastWriteTime.ToString("yyyy/MM/dd") -eq (Get-Date).ToString("yyyy/MM/dd") } | Get-ChildItem -Name | |
$outfile = $inputfile.Replace("xliff","txt") | |
$baseurl = "https://crowdin.com/translate/bible-app-bible-plans/" | |
function OutFile-ReadingPlanBodys($unit){ | |
$id = $unit.GetAttribute("id") | |
"`r`n`r`n"+$unit.note+" $baseurl#$id" | Out-File -Encoding utf8 -Append $outfile | |
"`r`ncode:en" | Out-File -Encoding utf8 -Append $outfile | |
"`t"+$unit.source | Out-File -Encoding utf8 -Append $outfile | |
if( $unit.target.GetAttribute("state") -match "translated"){ | |
"`r`ncode:translation" | Out-File -Encoding utf8 -Append $outfile | |
"`t"+$unit.target.'#text' | Out-File -Encoding utf8 -Append $outfile | |
} else { | |
"`r`ncode:translation" | Out-File -Encoding utf8 -Append $outfile | |
"`t"+$unit.target.'#text' | Out-File -Encoding utf8 -Append $outfile | |
} | |
} | |
$xml = [xml](Get-Content -Encoding UTF8 $inputfile) | |
$baseurl = "$baseurl"+ $xml.xliff.file.GetAttribute("id")+"/enus-ja" | |
$units = $xml.xliff.file.body.'trans-unit' | |
$unit = $units | Where-Object {$_.note.Contains("name")} | |
OutFile-ReadingPlanBodys($unit) | |
$unit = $units | Where-Object {$_.note.Contains("about")} | |
OutFile-ReadingPlanBodys($unit) | |
$unit = $units | Where-Object {$_.note.Contains("formatted_length")} | |
$format_day_length = $unit.source -replace "\D+?" | |
$format_day_length = [Int]$format_day_length | |
foreach( $count in 1..$format_day_length ){ | |
$unit = $units | Where-Object {$_.note.Equals("Context: day_$count")} | |
OutFile-ReadingPlanBodys($unit) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use this.