rvanbekkum / ps-xliff-sync

A PowerShell module to synchronize and validate XLIFF translation files.
MIT License
14 stars 5 forks source link

[Question] Help on Setup for Azure Devops #28

Closed pri-kise closed 2 years ago

pri-kise commented 2 years ago

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\'

https://github.com/rvanbekkum/ps-xliff-sync/blob/develop/XliffSync/Public/bc/Test-BcAppXliffTranslations.ps`

rvanbekkum commented 2 years ago

Hi @pri-kise,

Thanks for reaching out. You can add the following task to your .yml pipeline definition:

- task: PowerShell@2
  displayName: 'Check Translations'
  inputs:
    targetType: 'inline'
    script: |
      Test-BcAppXliffTranslations -AzureDevOps 'error' -printProblems

You'll have to have the XliffSync PowerShell module installed on your build server, e.g., Install-Module XliffSync.

Please note that it's best to run this task after compiling your app(s), so that you'll get a new .g.xlf file (of course the TranslationFile feature needs to be enabled). Then this command will first synchronize the translation files and then check for missing translations and problems in the translations.

The Test-BcAppXliffTranslations function assumes that you'll have the common setup in your repository, i.e.:

- $(Build.SourcesDirectory)
    - App
        - Translations
            - *.g.xlf
    - Test
        - ...

By default, all app folders will be checked, but you can specify explicitly for which app folders to check the translations by passing the -appFolders parameter, e.g., -appFolders @("App") (i.e., so without the $(Build.SourcesDirectory) part, so in the same way as you'd pass the -appFolders parameter to the BcContainerHelper's functions).

You can also find some more information on how to include translation checks in your build pipelines here: Checking XLIFF Translation Files for Errors in Build Pipelines

Hope this helps! 😊

P.S.: I also recently added a -FormatTranslationUnit parameter, so that you can control how detected problems are printed to the console. I am planning to change the default value for this parameter to the following in the next release:

-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')"

This will add a description of the detected problem to the output in the console (and in Azure DevOps error/warning messages).