ResourceTranslator.CLI 1.0.9

dotnet tool install --global ResourceTranslator.CLI --version 1.0.9                
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local ResourceTranslator.CLI --version 1.0.9                
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=ResourceTranslator.CLI&version=1.0.9                
nuke :add-package ResourceTranslator.CLI --version 1.0.9                

ResourceTranslator.CLI

This tool can translate your resource files with Microsoft Cognitive Service for translations To use this tool an azure TranslateApp is required. To create an Translate app and leran more about read this https://docs.microsoft.com/en-us/azure/cognitive-services/translator/quickstart-translator?tabs=csharp

Change log

  • 1.0.9 New option "Encoding" to specify encoding
  • 1.0.9 Support markdown files as input
  • 1.0.8 Option to skip existing output files
  • 1.0.7 Chunking Targets and Contents for Text files
  • 1.0.6 Allow big text content files as default if no dictionary can created. (For example usefull to translate *.md files)
  • 1.0.2 Only tranlate if translations are missing or overwrite option is passed

General

To install it

dotnet tool install --global ResourceTranslator.CLI

To update it

dotnet tool update ResourceTranslator.CLI -g

The easiest way to run it

 resourceTranslator --optionsfile "C:\PathToYourOptions\sampleOptions.json"

The passed options file can look like this for example

{
  "FileName": "C:\\dev\\myProject\\src\\Shared\\Resources\\en-US.yml",
  "TextTranslationEndpoint": "https://api.cognitive.microsofttranslator.com/",
  "ApiKey": "<your cognitive service api key>",
  "FileOutputFormat": "{FileName}.{Culture}.{Extension}",
  "OutputDir": "C:\\dev\\myProject\\src\\Shared\\Resources",
  "TargetCultures": "de-DE, es-ES, it-IT, sv-SE, en-GB",
  "SourceCulture": null,
  "Region": "germanywestcentral",
  "OutputFormat": null,
  "OverwriteExistingValuesWithNewTranslations": false,
  "AutoSort": true,
  "Encoding": "utf-8" // use "auto" to use the same encoding as the input file
}

Based on your input options for TargetCultures this tool creates translations for given input file FileName

image

Notice!: If a result file already exists only missing translations will be added.

Options

Name Alias Sample Is Required Description
FileName f -f "C:\path\file.json" yes The main input file to translate
TextTranslationEndpoint endpoint -endpoint "https://api.cognitive.microsofttranslator.com/" yes Endpoint for translation service
ApiKey key -key "<your api key>" yes Api key for translation service
Region region -region "germanywestcentral" yes Region where your azure cognitive service is stored
FileOutputFormat of -of "Generated_{FileName}_for_culture_{Culture}.{Extension}" no Format to save out put file
OutputDir outdir -outdir "C:\otherdir\" no Optional path to store result files in. Default is same dir as input file
TargetCultures target -target "de-DE, it-IT" yes Target cultures to generate translations for. Split by , or ; possible
OutputFormat format -format "Json" no Default same as input but if you want to convert yaml to json for example you can specify a format here
OverwriteExistingValuesWithNewTranslations overwritevalues -overwritevalues "True" no If this is true existing target resources will overwridden and not merged
AutoSort sort -sort "True" no If this is true all result files and the input file file sorted automatically Asc
SkipExistingOutputs skip -skip "True" no If this is true existing output files will not be changed (This setting is ignored for dictionaries and only used for Text based files)
Encoding encoding -encoding "auto" no "auto" is default then the same encoding as the entrance file is used, otherwise specify it here fallback is utf-8
Notice!: You can combine passing options file and overwrite only some parameters.

In this example all parameters are stored in a sampleOptions.json but api key and source file will be overwridden by call

resourceTranslator --optionsfile "C:\PathToYourOptions\sampleOptions.json" -key "diferentApiKey" -f "PathToMyFile.json"

Because this tool only translate if translations are missing by default you can easially use it on every Build to ensure your resource files are complete and sorted.

  <Target Name="Translate" AfterTargets="Build" Condition="'$(Configuration)' == 'Debug'">
    <Exec IgnoreExitCode="true" Command="dotnet tool install --global ResourceTranslator.CLI" />
    <Exec Command="resourceTranslator --optionsfile $(ProjectDir)resourceTranslationOptions.json -f $(ProjectDir)Resources\en-US.yml" />
  </Target>
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
1.0.9 481 11/20/2023
1.0.8 428 5/25/2022
1.0.7 414 5/19/2022
1.0.6 400 5/19/2022
1.0.5 404 5/19/2022
1.0.3 342 10/29/2021
1.0.2 350 10/27/2021
1.0.1 354 10/26/2021