A module to keep XLIFF translation files in sync with a specified, automatically generated base-XLIFF file.
This PowerShell module is based off the XLIFF Sync VSCode extension.
Initial version with support for XLIFF 1.2 (support for XLIFF 2.0 follows later).
You need to have Powershell 5.0 or newer. This module uses classes.
The Sync-XliffTranslations
function will synchronize translation units and translations for a specified base/source file and target file.
To use the function you will need to specify the path to the base/source file (-sourcePath
) and a path to the target file (-targetPath
) or a target language (-targetLanguage
).
An example usage:
Sync-XliffTranslations -sourcePath "C:\MyProject\My Project.g.xlf" -targetPath "C:\MyProject\My Project.nl-NL.xlf" -findByXliffGeneratorNoteAndSource -findByXliffGeneratorAndDeveloperNote -findByXliffGeneratorNote -reportProgress
The function will try to find matching trans-units and translations within a target file as follows:
- Finding trans-units:
- By Id
- By XLIFF Generator Note & Source (controlled by switch
findByXliffGeneratorNoteAndSource
)- By XLIFF Generator Note & Developer Note (controlled by switch
findByXliffGeneratorAndDeveloperNote
)- By XLIFF Generator Note (controlled by switch
findByXliffGeneratorNote
)
- Finding translations:
- By Source & Developer Note (controlled by switch
findBySourceAndDeveloperNote
)- By Source (controlled by switch
findBySource
)
- Initial translation:
- Parse from Developer Note (controlled by switch
parseFromDeveloperNote
)- Copy from Source if source-language = target-language (controlled by switch
copyFromSource
)
If no trans-unit or translation is found, the unit is added and its target node is tagged with state="needs-translation"
.
Please check the documentation of the function for more information and the available parameters.
The Check-XliffTranslations
function will check for missing translations and/or for problems in translations in a specified XLIFF file.
To use the function you will need to specify the target file (-targetPath
) and whether you want to check for missing translations (-checkForMissing
) and/or problems in translations (-checkForProblems
).
If you let the function check for problems, then you can use the translationRules
parameter to specify which technical validation rules should be applied.
An example usage:
Check-XliffTranslations -targetPath "C:\MyProject\My Project.nl-NL.xlf" -checkForMissing -reportProgress
When finished the function will report the number of missing translations and number of detected problems.
Translation units without translations will be marked with state="needs-translation"
and translation units with a problem in the translation will be marked with a 'needs-work' state and an "XLIFF Sync"-note that explains the detected problem.
Please check the documentation of the function for more information and the available parameters.
The Get-XliffTranslationsDiff
function will compare an original and new version of an XLIFF file and produce a new XLIFF Diff file that contains all the translation units that were added or whose source text was changed.
An example usage:
Get-XliffTranslationsDiff -originalPath "C:\MyProject\OriginalVersion.xlf" -newPath "C:\MyProject\NewVersion.xlf" -diffPath "C:\MyProject\Diff.xlf" -reportProgress
Please check the documentation of the function for more information and the available parameters.