TNTC 25.3.56810

dotnet tool install --global TNTC --version 25.3.56810
                    
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 TNTC --version 25.3.56810
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=TNTC&version=25.3.56810
                    
nuke :add-package TNTC --version 25.3.56810
                    

TNTC - The .NET Translation Tool

TNTC is a command-line tool designed to help manage translations in .NET projects. It extracts strings from source code, manages translations across multiple languages, and provides a structured workflow for handling localization. It is loosely inspired by the original TNT project, but fully implemented in C# and supporting LLM-based translations via an OpenAI integration.

Features

  • String Extraction: Automatically extracts translatable strings from C# source code
  • Multi-language Support: Handles translations for multiple languages including Chinese, German, French, Spanish, Italian, Portuguese, among others
  • Translation State Management: Tracks the state of translations (New, NeedsReview, NeedsReviewTranslation, Translated, Final)
  • JSON-based Storage: Stores translations in a structured JSON format, easily manageable on the source control of your code-base
  • Source Location Tracking: Keeps track of where translated strings were extracted from and used in the codebase

Installation

The tool requires .NET 9.0 or later. To install the tool globally, you can run:

dotnet tool install --global TNTC

You can also install the tool locally scoped to a project, see here for more information on installing dotnet tools.

Usage

Using TNTC on your source-code requires tagging all strings that need to be translated with a .t() method call.

For example:

var translatableString = "This string will be translated".t();  //Note the .t() added after the string
var fixedString        = "This string will be not translated";  

Interpolated strings can also be translated, but require a slightly different syntax to be able to capture them before they're interpolated:

var interpolatedString = t($"Today is {DateTimeOffset.UtcNow:u}");  //Note the t($"...") is added around the interpolated string

Command Line Commands

TNTC provides several commands:

Extract Command

tntc extract <projectFolder>

Extracts all strings from source files and updates translations. The tool will look for any folder with a .tnt folder as a project to be translated.

Note: This command requires an OpenAI API key to be set in the environment variable OPENAI_API_KEY for automatic translation functionality.

# Example with API key
export OPENAI_API_KEY='your-api-key-here'
tntc extract <projectFolder>

Source files are scanned for translatable strings using the Roslyn compiler.

Upgrade from TNT Command

tntc upgrade-from-tnt <projectFolder>

Upgrades existing TNT translations to the new JSON format. This is useful when migrating from an older version of the tool.

Translation Files Folder Structure

  • .tnt/: Configuration directory for translation settings
    • translation-{language}.json: Translation files for each supported language
    • extra-sources.json: Configuration for additional source directories
  • .tnt-content/: Directory containing the final translation files used by the application
    • Contains the processed and finalized translations ready for use
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
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
25.3.56810 137 3/18/2025
25.3.56597 162 3/10/2025
25.3.56595 147 3/10/2025
25.3.56593 160 3/10/2025
25.3.56592 158 3/10/2025
25.3.56590 152 3/10/2025
25.3.56589 159 3/10/2025