Skip to content

A PowerShell module to synchronize and validate XLIFF translation files.

License

Notifications You must be signed in to change notification settings

zabcik/ps-xliff-sync

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XLIFF Sync

License: MIT XliffSync

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.

Project Status

Initial version with support for XLIFF 1.2 (support for XLIFF 2.0 follows later).

Prerequisites

You need to have Powershell 5.0 or newer. This module uses classes.

Usage

Synchronize XLIFF Translations

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:

  1. Finding trans-units:
  1. By Id
  2. By XLIFF Generator Note & Source (controlled by switch findByXliffGeneratorNoteAndSource)
  3. By XLIFF Generator Note & Developer Note (controlled by switch findByXliffGeneratorAndDeveloperNote)
  4. By XLIFF Generator Note (controlled by switch findByXliffGeneratorNote)
  1. Finding translations:
  1. By Source & Developer Note (controlled by switch findBySourceAndDeveloperNote)
  2. By Source (controlled by switch findBySource)
  1. Initial translation:
  1. Parse from Developer Note (controlled by switch parseFromDeveloperNote)
  2. 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.

Check XLIFF Translations

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.

Get XLIFF Translation Files Diff

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.

About

A PowerShell module to synchronize and validate XLIFF translation files.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PowerShell 100.0%