DynamicTranslator 1.0.0

dotnet add package DynamicTranslator --version 1.0.0
                    
NuGet\Install-Package DynamicTranslator -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DynamicTranslator" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DynamicTranslator" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="DynamicTranslator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DynamicTranslator --version 1.0.0
                    
#r "nuget: DynamicTranslator, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DynamicTranslator@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DynamicTranslator&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=DynamicTranslator&version=1.0.0
                    
Install as a Cake Tool

DynamicTranslator

DynamicTranslator is a lightweight SDK for automatic response translation in ASP.NET Core APIs using attributes and IStringLocalizer.
Easily localize API responses without writing repetitive localization logic.


πŸ“¦ Installation

dotnet add package DynamicTranslator

βš™οΈ Configuration

In your Program.cs, add the following:

// Localization resources configuration
builder.Services.AddDynamicTranslator(options =>
{
    options.ResourceType = typeof(Resources); // Your default .resx resource
});

// Register translation filter
builder.Services.AddControllers(options =>
{
    options.Filters.Add<GenericTranslationFilter>();
});

πŸ“ Localization folder structure

Create a folder called Localization/ in the root of your project and add your .resx files:

/YourProject
β”‚
β”œβ”€β”€ Localization/
β”‚   β”œβ”€β”€ Resources.resx              // Default (e.g., pt-BR)
β”‚   β”œβ”€β”€ Resources.en.resx           // English
β”‚   β”œβ”€β”€ Resources.es.resx           // Spanish
β”‚   └── Resources.fr.resx           // French

The Resources file must contain the translated keys used in your models or attributes.
Each .resx file should follow the ResourceManager naming convention.


🏷️ Attributes

Use the following attributes in your response models:

  • [IgnoreTranslation] β†’ Skips a specific property
  • [DisableTranslator] β†’ Skips the entire object

Example:

public class ProductResponse
{
    [IgnoreTranslation]
    public string Name { get; set; }

    public string Type { get; set; }
}

🌐 Accept-Language header

Translation will automatically be applied based on the Accept-Language header sent in the request.

Example:

GET /api/products
Accept-Language: pt-BR

βœ… Example response before/after

Input (en-US):

{
  "name": "Tesla Model Y",
  "type": "Electric Vehicle"
}

Translated (Accept-Language: pt-BR):

{
  "name": "Tesla Model Y",
  "type": "VeΓ­culo ElΓ©trico"
}

πŸ“š License

MIT Β© Ulisses InΓ‘cio

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  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.  net9.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 150 5/4/2025