ResourceTranslator.CLI 1.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global ResourceTranslator.CLI --version 1.0.5                
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.5                
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=ResourceTranslator.CLI&version=1.0.5                
nuke :add-package ResourceTranslator.CLI --version 1.0.5                

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.2 Only tranlate if translations are missing or overwrite option is passed

General

To install it

dotnet tool install --global ResourceTranslator.CLI

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
}

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
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 was computed.  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 was computed.  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 350 11/20/2023
1.0.8 406 5/25/2022
1.0.7 392 5/19/2022
1.0.6 377 5/19/2022
1.0.5 382 5/19/2022
1.0.3 321 10/29/2021
1.0.2 326 10/27/2021
1.0.1 332 10/26/2021