rvanbekkum / ps-xliff-sync Goto Github PK
View Code? Open in Web Editor NEWA PowerShell module to synchronize and validate XLIFF translation files.
License: MIT License
A PowerShell module to synchronize and validate XLIFF translation files.
License: MIT License
When I ran
Sync-XliffTranslations -sourcePath '.\Translations\MyCompanyName Extension.g.xlf' -targetPath .\Translations\translation.nl-NL.xlf -targetLanguage nl-NL -findBySourceAndDeveloperNote
from the folder of my AL-project, the cmdlet claims that the source path could not be found, but it appears to be looking for it in my home folder (c:\Users\MyUserName
). Please consider adding support for relative paths, such as ".\Translations\MyFile.txt" and "..\Translations\MyFile.txt".
P.S.: I haven't tested this, but the cmdlets may also lack support for special paths such as PowerShell drives (MyDrive:\MyFile.txt) and ~ (which represents the user's home folder).
Running Check-XliffTranslations you always get the details about the missing/problematic translations. Using it in DevOps pipelines or some other process you may not always be interested in all this info. Just knowing that there are missing/problematic translations in the file is sometimes enough.
In the current implementation of Sync-XliffTranslations, either the -targetPath or the -targetLanguage parameter can be left blank, but not both, effectively meaning that you need to tell Sync-XliffTranslations in advance which languages you wish to process.
In our use case, we would like to add translations for different languages in our AL files, then use Sync-XliffTranslations to create/update the XLIFF files for any languages found in the developer comments. In that situation, -targetLanguage could still be used as an optional filter to limit which languages to process.
Allowing multiple languages to be handled in a single invocation would probably render -targetPath obsolete (since there could be many target paths - one for each language found). I think this would potentially break existing scripts, and I'm not (yet) sure how to work around that.
I have a messages.xlf
and a messages.en-US.xlf
file. If a source node gets modified in messages.xlf
, it appears in messages.en-US.xlf
as the target state is needs-adaptation
, and a note is added saying that the source text has changed.
<trans-unit id="test" datatype="html">
<source>Modified text</source>
<target state="needs-adaptation">Original text</target>
<note from="XLIFF Sync" annotates="general" priority="1">Source text has changed. Please review the translation.</note>
<context-group purpose="location">
<context context-type="sourcefile">src/app/overview/component/current-status/current-status-advanced-filter/current-status-advanced-filter.component.ts</context>
<context context-type="linenumber">276</context>
</context-group>
</trans-unit>
This is totally OK.
But, if I re-run the same command, the <note>
node gets removed, but everything else stays the same. The expected result would be that the note remains there if the target's state is still needs-adaptation
.
Command used for generation:
Sync-XliffTranslations -sourcePath "messages.xlf" -targetPath "messages.en-US.xlf"
messages.xlf
used:
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="dev" datatype="plaintext" original="ng2.template">
<body>
<trans-unit id="test" datatype="html">
<source>Modified text</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/overview/component/current-status/current-status-advanced-filter/current-status-advanced-filter.component.ts</context>
<context context-type="linenumber">276</context>
</context-group>
</trans-unit>
</body>
</file>
</xliff>
Currently I get the following error when I run Test-BcAppXliffTranslations in my pipeline. Below is the YAML step and the error message from the log
Where-Object : The property 'Name' cannot be found on this object. Verify that the property exists.
At C:\Program
Files\WindowsPowerShell\Modules\BcContainerHelper\4.0.6\AppHandling\Sort-AppFoldersByDependencies.ps1:125 char:13
$apps | Where-Object { $_.Name -eq "Application" } | ForEach-Obje ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
YAML Step after "Run Pipeline"
I'm (unfortunately) able to reproduce that error locally on my machine in various repositories and folder structures
Standard PowerShell cmdlets whose return value is, in most use cases, irrelevant tend to have a -PassThru
parameter. Only if this switch parameter is set will the cmdlet write objects to the output stream.
Test-XliffTranslations, when used from Azure Devops, reports its findings in the pipeline's log. Only rarely will anybody be interested in the returned translation units in that scenario. Perhaps you would consider adding a new -PassThru
parameter as a condition for returning $missingTranslationUnits
and $needWorkTranslationUnits
?
(Until then, I'll just pipe the results to Out-Null.)
I ran Sync-XliffTranslations
with a path that the cmdlet considered invalid (see also my other issue). As a result, the file could not be loaded and I got this error message:
Exception calling "Load" with "1" argument(s): "Could not find a part of the path 'C:\Users\MyUserName\Translations\MyCompanyName Extension.g.xlf'."
However, execution continued as normal, leading to a wall of red text. Subsequent attemps to load other files (i.c. the target file) failed for the same reason.
I would argue that file load failures should be treated as fatal, and execution should stop immediately.
Settings
"xliffSync.autoCheckMissingTranslations": true,
"xliffSync.autoCheckNeedWorkTranslations": true,
"xliffSync.needWorkTranslationRules": [
"OptionMemberCount",
"OptionLeadingSpaces",
"Placeholders",
"ConsecutiveSpacesConsistent",
"ConsecutiveSpacesExist"
],
"xliffSync.parseFromDeveloperNote": true,
"xliffSync.parseFromDeveloperNoteOverwrite": true,
"xliffSync.parseFromDeveloperNoteSeparator": "||",
"xliffSync.findBySource": true,
"xliffSync.findBySourceAndDeveloperNote": true,
"xliffSync.parseFromDeveloperNoteTrimCharacters": "\"",
"xliffSync.preserveTargetAttributesOrder": true,
When packaging an app in VS Code, I get following trans-unit id in the g.xlf file
<trans-unit id="Codeunit 2906659059 - NamedType 2580332125" size-unit="char" translate="yes" xml:space="preserve">
<source>Suggests to open the Drinkmaster 365 apps landing page</source>
<note from="Developer" annotates="general" priority="2"></note>
<note from="Xliff Generator" annotates="general" priority="3">Codeunit ESCG Drinkmaster Notification - NamedType NotificationDescriptionTxt</note>
</trans-unit>
Running the 'Synchronize Translation Units' in VS Code results in following trans-unit id in the nl-BE.xlf file
<trans-unit id="Codeunit 2906659059 - NamedType 2580332125" size-unit="char" translate="yes" xml:space="preserve">
<source>Suggests to open the Drinkmaster 365 apps landing page</source>
<target state="translated">Stelt voor om de Drinkmaster 365 apps landingspagina te openen</target>
<note from="Developer" annotates="general" priority="2"/>
<note from="Xliff Generator" annotates="general" priority="3">Codeunit ESCG Drinkmaster Notification - NamedType NotificationDescriptionTxt</note>
</trans-unit>
Script
$AppFolders = @("App")
$SyncAdditionalParameters = @{
"preserveTargetAttributesOrder" = $true
"findBySource" = $true
"findBySourceAndDeveloperNote" = $true
"parseFromDeveloperNote" = $true
"parseFromDeveloperNoteOverwrite" = $true
"parseFromDeveloperNoteSeparator" = "||"
# parseFromDeveloperNoteTrimCharacters" = "\""
}
Test-BcAppXliffTranslations -printProblems -appFolders $AppFolders -translationRules @("OptionMemberCount", "OptionLeadingSpaces", "Placeholders", "ConsecutiveSpacesConsistent", "ConsecutiveSpacesExist") -restrictErrorsToLanguages @("nl-BE", "nl-NL") -buildProjectFolder $BuildProjectFolder -syncAdditionalParameters $SyncAdditionalParameters
This results in following trans-unit id in the nl-BE.xlf file
<trans-unit id="Codeunit 2906659059 - NamedType 2580332125" size-unit="char" translate="yes" xml:space="preserve">
<source>Suggests to open the Drinkmaster 365 apps landing page</source>
<target state="translated">Stelt voor om de Drinkmaster 365 apps landingspagina te openen</target>
<note from="Developer" annotates="general" priority="2"></note>
<note from="Xliff Generator" annotates="general" priority="3">Codeunit ESCG Drinkmaster Notification - NamedType NotificationDescriptionTxt</note>
</trans-unit>
These seems to be a difference in the sync results (I guess my settings in VS Code and PS should be the same) when ran in VS Code vs Powershell.
<note from="Developer" annotates="general" priority="2"/>
<note from="Developer" annotates="general" priority="2"></note>
In our pipelines, we perform a compile step, then run a Test-BcAppXliffTranslations step and conditionally re-compile the app with the updated xliffs. The re-compile is ran conditionally espc. to save build time when no changes to translation file changes had been detected (checked via Get-FileHash).
However, due to the differences in above results, the re-compile is always ran. Any advice / inputs or possible fix?
PS: Another nice option would be if Test-BcAppXliffTranslations could return whether any of the xliff files has actually changed by the command.
I have a messages.xlf
file generated by angular, which has several sources, where there are <x/>
nodes inside the source:
<source><x id="PH" equiv-text="olderThanParam"/> day</source>
.
When using -copyFromSource
param to copy this to the messages.en-US.xlf
file, the source is copied just fine, but the target is either incomplete or completely missing.
If the x node is in the beginning of the source, it is missing completely, if it's in somewhere in the source (but not at the start), the target gets filled until the x node.
<source><x id="PH" equiv-text="olderThanParam" /> day</source>
<target state="needs-translation" />
<source>Should have <x id="PH" equiv-text="olderThanParam" /> days</source>
<target state="translated">Should have </target>
Command used: Sync-XliffTranslations -sourcePath "messages.xlf" -targetPath "messages.en-US.xlf" -copyFromSource
The messages.xlf
generating this problem:
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="dev" datatype="plaintext" original="ng2.template">
<body>
<trans-unit id="startWithXNode" datatype="html">
<source><x id="PH" equiv-text="olderThanParam"/> day</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/overview/component/current-status/current-status-advanced-filter/current-status-advanced-filter.component.ts</context>
<context context-type="linenumber">276</context>
</context-group>
</trans-unit>
<trans-unit id="hasXNodeInTheMiddle" datatype="html">
<source>Should have <x id="PH" equiv-text="olderThanParam"/> days</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/overview/component/current-status/current-status-advanced-filter/current-status-advanced-filter.component.ts</context>
<context context-type="linenumber">276</context>
</context-group>
</trans-unit>
</body>
</file>
</xliff>
Hi @rvanbekkum ,
We've finally moved the translation logic to our pipelines and are 99% close to auto-generate translations as part of the build process. However, we lack support for the parseFromDeveloperNoteTrimCharacters
setting in PS Xliff Sync (although it is supported in VS Code > rvanbekkum/vsc-xliff-sync#100)
Our PS script currently looks like this ...
...
$SyncAdditionalParameters = @{
"preserveTargetAttributesOrder" = $true
"findBySource" = $true
"findBySourceAndDeveloperNote" = $true
"parseFromDeveloperNote" = $true
"parseFromDeveloperNoteOverwrite" = $true
"parseFromDeveloperNoteSeparator" = "||"
# parseFromDeveloperNoteTrimCharacters" = "\"" ### <<< This is currently missing
}
...
Test-BcAppXliffTranslations -printProblems -appFolders $AppFolders -translationRules @("OptionMemberCount", "OptionLeadingSpaces", "Placeholders", "ConsecutiveSpacesConsistent", "ConsecutiveSpacesExist") -restrictErrorsToLanguages @("nl-BE", "nl-NL") -buildProjectFolder $BuildProjectFolder -syncAdditionalParameters $SyncAdditionalParameters -AzureDevOps $AzureDevOps # -reportProgress -FormatTranslationUnit
... but we would like to specify parseFromDeveloperNoteTrimCharacters
similar to how we can specify this in VS Code.
Any chance of integrating below commit into the PS version of XLiff Sync?
rvanbekkum/vsc-xliff-sync@fc0ba6a
Microsoft strongly encourages PowerShell developers to follow certain guidelines when it comes to naming cmdlets to facilitate their discoverability. Use Get-Verb
in PowerShell to get a list of approved verbs and their typical usages.
Since your module is already published, changing your cmdlet names now may break existing user scripts. However, what you may want to consider is to change your cmdlet names to comply with Microsofts guidelines, and, where appropriate, give each cmdlet a so called alias that contains the old, non-compliant name. That way, user scripts will not be broken.
Hi, I recently discoverd this repo an tried to replace our current solution in Azure DevOps to check for missing translations.
Maybe you can give me some guideance to replace our current XliffCheck.
Rigth now we are using the following project compiled as executable and placed in a network share
https://github.com/DanielGoehler/XliffCheck
As far as I can see, your powershell solution contains all these checks, too.
Right now I have the following task after compiling the app to get an *g.xlf
file.
- task: CmdLine@2
displayName: "Check Xliff Files"
inputs:
script: '"\\files\DevOps\Common\XliffCheck\App.exe" $(Build.SourcesDirectory)\MainApp\Translations\'
I guess that I would need somehow a step to download the module on my build agent Install-Module -Name XliffSync
and additionally a step to execute the check, but I'm not sure how to that...
- task: CmdLine@2
displayName: "Check Xliff Files"
inputs:
script: 'Test-BcAppXliffTranslations -translationRulesEnableAll -AzureDevOps 'error' -printProblems' - appFolders '$(Build.SourcesDirectory)\MainApp\'
When examining the differences introduced by a pull request, it's nice not to be distracted by false positives due to different code formatting styles (e.g. spaces around operators, placement of curly brackets, use of new line characters etc.) - relevant changes could easily be missed in a haystack of "noise".
Before working on any other pull requests, I would like to suggest the introduction of a workspace settings file containing the project's formatting rules. By putting this into the repo, all developers use the same rules (as workspace settings override user settings).
Note that this assumes that most people these days use VS Code to edit their PowerShell files.
Hello,
we have the following two XLF-Files:
First File
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<file datatype="xml" source-language="en-US" target-language="de-DE" original="Please update this value">
<body>
<group id="body">
<trans-unit id="Table 3993789018 - Property 2879900210" maxwidth="0" size-unit="char" translate="yes" xml:space="preserve">
<source>AAD Application</source>
<target state="translated">AAD-Anwendung</target>
<note from="Developer" annotates="general" priority="2" />
<note from="Xliff Generator" annotates="general" priority="3">Table AAD Application - Property Caption</note>
</trans-unit>
<trans-unit id="Codeunit 279185018 - NamedType 3458570292" size-unit="char" translate="yes" xml:space="preserve">
<source>The Type is not supported by the Evaluate function.</source>
<target>Der Typ wird von der Bewertungsfunktion nicht unterstützt.(something changed here)</target>
<note from="Developer" annotates="general" priority="2" />
<note from="Xliff Generator" annotates="general" priority="3">Codeunit Type Helper - NamedType UnsupportedTypeErr</note>
</trans-unit>
</group>
</body>
</file>
</xliff>
second file:
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<file datatype="xml" source-language="en-US" target-language="de-DE" original="Please update this value">
<body>
<group id="body">
<trans-unit id="Codeunit 279185018 - NamedType 3458570292" size-unit="char" translate="yes" xml:space="preserve">
<source>The Type is not supported by the Evaluate function.</source>
<target>Der Typ wird von der Bewertungsfunktion nicht unterstützt.</target>
<note from="Developer" annotates="general" priority="2" />
<note from="Xliff Generator" annotates="general" priority="3">Codeunit Type Helper - NamedType UnsupportedTypeErr</note>
</trans-unit>
</group>
</body>
</file>
</xliff>
Now I want to synchronize the changes from the second file into the first file.
This means that the expected result would look like this:
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<file datatype="xml" source-language="en-US" target-language="de-DE" original="Please update this value">
<body>
<group id="body">
<trans-unit id="Table 3993789018 - Property 2879900210" maxwidth="0" size-unit="char" translate="yes" xml:space="preserve">
<source>AAD Application</source>
<target state="translated">AAD-Anwendung</target>
<note from="Developer" annotates="general" priority="2" />
<note from="Xliff Generator" annotates="general" priority="3">Table AAD Application - Property Caption</note>
</trans-unit>
<trans-unit id="Codeunit 279185018 - NamedType 3458570292" size-unit="char" translate="yes" xml:space="preserve">
<source>The Type is not supported by the Evaluate function.</source>
<target>Der Typ wird von der Bewertungsfunktion nicht unterstützt.</target>
<note from="Developer" annotates="general" priority="2" />
<note from="Xliff Generator" annotates="general" priority="3">Codeunit Type Helper - NamedType UnsupportedTypeErr</note>
</trans-unit>
</group>
</body>
</file>
</xliff>
But instead the first trans-unit gets deleted and the second one remains unchanged:
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<file datatype="xml" source-language="en-US" target-language="de-DE" original="Please update this value">
<body>
<group id="body">
<trans-unit id="Codeunit 279185018 - NamedType 3458570292" size-unit="char" translate="yes" xml:space="preserve">
<source>The Type is not supported by the Evaluate function.</source>
<target>Der Typ wird von der Bewertungsfunktion nicht unterstützt.(something changed here)</target>
<note from="Developer" annotates="general" priority="2" />
<note from="Xliff Generator" annotates="general" priority="3">Codeunit Type Helper - NamedType UnsupportedTypeErr</note>
</trans-unit>
</group>
</body>
</file>
</xliff>
Is there any way to keep the first one plus the changes in the second one?
If I try it the other way round I get both trans-units, but the first one lacks the target:
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<file datatype="xml" source-language="en-US" target-language="de-DE" original="Please update this value">
<body>
<group id="body">
<trans-unit id="Table 3993789018 - Property 2879900210" maxwidth="0" size-unit="char" translate="yes" xml:space="preserve">
<source>AAD Application</source>
<target state="needs-translation" />
<note from="Developer" annotates="general" priority="2" />
<note from="Xliff Generator" annotates="general" priority="3">Table AAD Application - Property Caption</note>
</trans-unit>
<trans-unit id="Codeunit 279185018 - NamedType 3458570292" size-unit="char" translate="yes" xml:space="preserve">
<source>The Type is not supported by the Evaluate function.</source>
<target>Der Typ wird von der Bewertungsfunktion nicht unterstützt.</target>
<note from="Developer" annotates="general" priority="2" />
<note from="Xliff Generator" annotates="general" priority="3">Codeunit Type Helper - NamedType UnsupportedTypeErr</note>
</trans-unit>
</group>
</body>
</file>
</xliff>
The command I used is the following:
Sync-XliffTranslations `
-sourcePath "C:\Temp\second.xlf" `
-targetPath "C:\Temp\first.xlf" `
-reportProgress `
-parseFromDeveloperNoteOverwrite `
-findByXliffGeneratorNoteAndSource -findByXliffGeneratorAndDeveloperNote -findByXliffGeneratorNote
What am I doing wrong?
Kind Regards
Michael
I realy like this whole project!
Is there an opportunity to host this on Powershell Gallery to "install-Module" it? :)
Our development main / source language to provide captions is en-US. When generating the en-US xlf file, our current process is to take a copy of the g.xlf file (source-language 'en-US'), overwrite the en-US.xlf file (with target language 'en-US'), open in poEdit and apply a ctrl-B to take over the source language as target language. This is the fastest way I've found to keep at least the 'en-US' file synced (in case of large 30mb+ files).
Scripting this step with Sync-XliffTranslations function for this scenario seems like overkill seems it does a lot of comparions, where in fact the file could you be recreated instead based on the updated source file.
Would it be an idea to implement the above logic via a separate 'Clone-XliffTranslation' function with :
-sourcePath "C:\MyProject\My Project.g.xlf" -targetPath "C:\MyProject\My Project.en-US.xlf" -targetLanguage "en-US" -reportProgress
Currently, in Test-XliffTranslation, for each missing and incorrect translation entry, the ID is written to the host (in our case: Azure Devops Pipelines log).
$missingTranslationUnits | ForEach-Object {
Write-Host ($detectedMessage -f $_.id);
}
This leads to log entries that look like this:
2021-11-08T14:00:29.3495600Z ##[warning]Missing translation in unit 'Table 476401740 - Field 3249588532 - Property 62802879'.
I think most users would like some influence on the way these things are reported - the actual table ID, field no. and property name would certainly help in the example above.
My suggestion would be a scriptblock parameter that accepts a single XmlNode (the translation unit) and returns the string that you want to send to Write-Host. The default value for the parameter could be a scriptblock that returns the ID property of the translation unit it receives, so that the out-of-the-box behaviour remains as it is today.
Test-BcAppXliffTranslations
is a wrapper around Sync-XliffTranslations
and Test-XliffTranslations
for BC apps, but you do not have as much freedom to pass the respective parameters of these functions through.
Please align the parameters and/or allow them to be passed on through (a) special parameter(s).
I've a project with following XliffSync settings:
"xliffSync.baseFile": "Navitrans 365 Core.g.xlf",
"xliffSync.findBySource": true,
"xliffSync.missingTranslation": "%EMPTY%",
"xliffSync.autoCheckNeedWorkTranslations": true,
"xliffSync.autoCheckMissingTranslations": true,
When manually synching g.xliff to nl-be.xliff (via synchronize translation units
in VSCode), I get a message for 2 missing translations (ok) and 1 translation that needs work (fine !!)
This is indeed marked in the nl-be.xliff file
<target state="needs-adaptation">Opmerkingen</target>
Re-running the synchronize translation units
in VSCode, gives the same message: 2 missing translations (ok) and 1 translation that needs work (fine !!)
I've integrated the above in a pipeline using PS-xliff-sync, to ensure translations are synced as part of the build process and we use the output as build artifact, to have an idea on the amount of work needed to translate our apps. This works for the missing translations, but seems not to list the 'translations that need work'.
Running a PS script to check on missing translations and to check for problems ...
$WorkspaceFolder = 'C:\GIT\Navitrans.Core\'
$SourceFile = Join-Path $WorkspaceFolder "App\Translations\Navitrans 365 Core.g.xlf"
Sync-XliffTranslations -sourcePath $SourceFile -targetPath (Join-Path $WorkspaceFolder "App\Translations\Navitrans 365 Core.nl-BE.xlf") -reportProgress
Check-XliffTranslations -targetPath (Join-Path $WorkspaceFolder "App\Translations\Navitrans 365 Core.nl-BE.xlf") -checkForMissing -reportProgress -checkForProblems -translationRules ConsecutiveSpacesConsistent, ConsecutiveSpacesExist, OptionLeadingSpaces, OptionMemberCount, Placeholders
... only provide this output
Detected: 2 missing translation(s).
Missing translation in unit 'Enum 870401921 - EnumValue 3355985101 - Property 2879900210'.
Missing translation in unit 'Enum 870401921 - EnumValue 4008471815 - Property 2879900210'.
Detected: 0 translation(s) that need work. <<<< ?
I expected to see the same result as in VSCode, that 1 translation needed work (instead of 0).
Is there something wrong with my settings?
In Test-XliffTranslations
, you append (potentially numerous) items to the $missingTranslationUnits
and $needWorkTranslationUnits
arrays. In PowerShell (.NET), this is an expensive operation (increasingly so for larger arrays) that can easily be avoided by capturing the items emitted (i.c. by the ForEach-Object command), then storing them in an array all at once.
Please consider the performance difference in the (admittedly simple) example below.
When running Sync-XliffTranslations, for a language where there is no translation file yet, I get this error:
>> Sync-XliffTranslations -sourcePath "$GeneralXlf" -targetLanguage "de-DE" -findByXliffGeneratorNoteAndSource -findByXliffGeneratorAndDeveloperNote -findByXliffGeneratorNote
Loading source document C:\...\Translations\My Extension.g.xlf
Creating new document for language 'de-DE'
Ausnahme beim Festlegen von "target-language": "Die Eigenschaft "target-language" wurde für dieses Objekt nicht gefunden. Vergewissern Sie sich, dass die Eigenschaft vorhanden ist und festgelegt werden kann."
In C:\Program Files\WindowsPowerShell\Modules\XliffSync\1.6.0.0\Model\XlfDocument.ps1:707 Zeichen:17
+ $newFileNode.'target-language' = $language;
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], SetValueInvocationException
+ FullyQualifiedErrorId : ExceptionWhenSetting
Es ist nicht möglich, eine Methode für einen Ausdruck aufzurufen, der den NULL hat.
In C:\Program Files\WindowsPowerShell\Modules\XliffSync\1.6.0.0\Public\Sync-XliffTranslations.ps1:126 Zeichen:5
+ [string] $language = $targetDocument.GetTargetLanguage();
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Creating Maps in memory for target document's units.
Translation of the error message: The propery "target-language" was not found for this object. Please make sure that the property exists and can be set.
Also, if I have generated the translation file in VSCode, and then run the powershell script, the attribute target-language disappears from the translation file.
Hi, first of all thank you for this very useful tool.
It happens something strange when i try to use it. I have and angular application and i extracted an xlf file named messages.xlf using ng i18n-extract ( it is the file attached to the issue ), i copied and renamed it into messages.it.xlf. Then i run ng i18n-extract again because some translations have been added to the app, so the messages.xlf now contains more entries. Here comes xliff sync tool: when i run
Sync-XliffTranslations -sourcePath "src\locale\messages.xlf" -targetPath "src\locale\messages.it.xlf"
the file messages.it.xlf is correctly merged, but in the console i get a lot of errors like this
Exception calling "ImportNode" with "2" argument(s): "Cannot import a null node."
At C:\Program Files\WindowsPowerShell\Modules\XliffSync\1.0.0.0\Model\XlfDocument.ps1:509 char:21
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
why? how can i get rid of these errors?
Thank you very much in advance
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.