Skip to content

Commit

Permalink
Merge branch 'release/1.9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
rvanbekkum committed May 19, 2023
2 parents af2e605 + d543a68 commit d4ee2de
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## [1.9.0] 19-05-2023

* Added `-useSelfClosingTags` parameter to the `Sync-XliffTranslations` command (GitHub issue [#38](https://github.com/rvanbekkum/ps-xliff-sync/issues/38))
* Added `-processAppFoldersSortedByDependencies` parameter to the `Test-BcAppXliffTranslations` command.

### Thank You (for 1.9.0)

* [Frédéric Vercaemst](https://github.com/fvet) for filing [Issue #38 Different Developer closing note when syncing xliffs via PS vs VS Code](https://github.com/rvanbekkum/ps-xliff-sync/issues/38)

## [1.8.0] 28-01-2023

* Added `-parseFromDeveloperNoteTrimCharacters` parameter to the `Sync-XliffTranslations` command (GitHub issue [#39](https://github.com/rvanbekkum/ps-xliff-sync/issues/39))
Expand Down
8 changes: 8 additions & 0 deletions XliffSync/Model/XlfDocument.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class XlfDocument {
[boolean] $preserveTargetAttributesOrder;
[string] $parseFromDeveloperNoteSeparator;
[string] $missingTranslation;
[boolean] $useSelfClosingTags;

[boolean] Valid() {
$hasRoot = $null -ne $this.root;
Expand Down Expand Up @@ -638,6 +639,13 @@ class XlfDocument {
if (Test-Path $filePath) {
$filePath = Resolve-Path $filePath
}

if ($this.useSelfClosingTags) {
foreach ($elem in $this.root.OwnerDocument.SelectNodes("descendant::*[not(node())]")) {
$elem.IsEmpty = $true;
}
}

$this.root.OwnerDocument.Save($filePath);
}

Expand Down
4 changes: 4 additions & 0 deletions XliffSync/Public/Sync-XliffTranslations.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
Specifies whether the command should report progress.
.Parameter printProblems
Specifies whether the command should print all detected problems.
.Parameter useSelfClosingTags
Specifies whether the updated target document should use self-closing XML tags.
.Parameter FormatTranslationUnit
A scriptblock that determines how translation units are represented in warning/error messages.
By default, the ID of the translation unit is returned.
Expand Down Expand Up @@ -90,6 +92,7 @@ function Sync-XliffTranslations {
[string] $AzureDevOps = 'no',
[switch] $reportProgress,
[switch] $printProblems,
[switch] $useSelfClosingTags,
[ValidateNotNull()]
[ScriptBlock]$FormatTranslationUnit = { param($TranslationUnit) $TranslationUnit.id }
)
Expand All @@ -112,6 +115,7 @@ function Sync-XliffTranslations {
$mergedDocument.parseFromDeveloperNoteSeparator = $parseFromDeveloperNoteSeparator;
$mergedDocument.preserveTargetAttributes = $preserveTargetAttributes;
$mergedDocument.preserveTargetAttributesOrder = $preserveTargetAttributesOrder;
$mergedDocument.useSelfClosingTags = $useSelfClosingTags;

[XlfDocument] $targetDocument = $null;
if (-not $targetPath) {
Expand Down
14 changes: 12 additions & 2 deletions XliffSync/Public/bc/Test-BcAppXliffTranslations.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
Specifies whether the command should print all detected problems.
.Parameter printUnitsWithErrors
Specifies whether the command should print the units with errors.
.Parameter useSelfClosingTags
Specifies whether the updated target document should use self-closing XML tags.
.Parameter processAppFoldersSortedByDependencies
Specifies whether the command should process the app folders in order of app dependencies (uses module BcContainerHelper for sorting).
.Parameter FormatTranslationUnit
A scriptblock that determines how translation units are represented in warning/error messages.
By default, the Xliff Generator note and XLIFF Sync note of the translation unit is returned.
Expand All @@ -47,6 +51,8 @@ function Test-BcAppXliffTranslations {
[switch] $reportProgress,
[switch] $printProblems,
[switch] $printUnitsWithErrors,
[switch] $useSelfClosingTags,
[switch] $processAppFoldersSortedByDependencies,
[ValidateNotNull()]
[ScriptBlock]$FormatTranslationUnit = { param($TranslationUnit) "$($TranslationUnit.note | Where-Object from -EQ 'Xliff Generator' | Select-Object -ExpandProperty '#text'): $($TranslationUnit.note | Where-Object from -EQ 'XLIFF Sync' | Select-Object -ExpandProperty '#text')" },
$syncAdditionalParameters = @{},
Expand All @@ -58,7 +64,11 @@ function Test-BcAppXliffTranslations {
Write-Host "-appFolders not explicitly set, using subfolders of $($buildProjectFolder): $appFolders"
}

Sort-AppFoldersByDependencies -appFolders $appFolders -baseFolder $buildProjectFolder -WarningAction SilentlyContinue | ForEach-Object {
if ($processAppFoldersSortedByDependencies) {
$appFolders = Sort-AppFoldersByDependencies -appFolders $appFolders -baseFolder $buildProjectFolder -WarningAction SilentlyContinue
}

$appFolders | ForEach-Object {
Write-Host "##[group]Checking translations for `"$_`""
$appProjectFolder = Join-Path $buildProjectFolder $_
$appTranslationsFolder = Join-Path $appProjectFolder "Translations"
Expand All @@ -80,7 +90,7 @@ function Test-BcAppXliffTranslations {
}

Write-Host "Syncing to file $($targetXliffFile.FullName)"
$unitsWithIssues += Sync-XliffTranslations -sourcePath $baseXliffFile.FullName -targetPath $targetXliffFile.FullName -AzureDevOps $AzureDevOpsSeverityForFile -reportProgress:$reportProgress -printProblems:$printProblems -FormatTranslationUnit $FormatTranslationUnit @syncAdditionalParameters
$unitsWithIssues += Sync-XliffTranslations -sourcePath $baseXliffFile.FullName -targetPath $targetXliffFile.FullName -AzureDevOps $AzureDevOpsSeverityForFile -reportProgress:$reportProgress -printProblems:$printProblems -useSelfClosingTags:$useSelfClosingTags -FormatTranslationUnit $FormatTranslationUnit @syncAdditionalParameters
Write-Host "Checking translations in file $($targetXliffFile.FullName)"
$unitsWithIssues += Test-XliffTranslations -targetPath $targetXliffFile.FullName -checkForMissing -checkForProblems -translationRules $translationRules -translationRulesEnableAll:$translationRulesEnableAll -AzureDevOps $AzureDevOpsSeverityForFile -reportProgress:$reportProgress -FormatTranslationUnit $FormatTranslationUnit -printProblems:$printProblems @testAdditionalParameters

Expand Down
4 changes: 2 additions & 2 deletions XliffSync/XliffSync.psd1
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@{
RootModule = 'XliffSync.psm1'
ModuleVersion = '1.8.0.0'
ModuleVersion = '1.9.0.0'
GUID = 'a7614fd7-ce84-44db-9475-bc1f5fa4f0e5'
Author = 'Rob van Bekkum'
CompanyName = 'WSB Solutions B.V.'
Copyright = '(c) 2022 Rob van Bekkum. All rights reserved.'
Copyright = '(c) 2023 Rob van Bekkum. All rights reserved.'
Description = 'Keep XLIFF translation files easily in sync with a generated base-XLIFF file.'
PowerShellVersion = '5.0'
FunctionsToExport = @('Get-XliffTranslationsDiff', 'Set-XliffTranslations', 'Sync-XliffTranslations', 'Test-BcAppXliffTranslations', 'Test-XliffTranslations')
Expand Down

0 comments on commit d4ee2de

Please sign in to comment.