DynamicTranslator 1.0.0
dotnet add package DynamicTranslator --version 1.0.0
NuGet\Install-Package DynamicTranslator -Version 1.0.0
<PackageReference Include="DynamicTranslator" Version="1.0.0" />
<PackageVersion Include="DynamicTranslator" Version="1.0.0" />
<PackageReference Include="DynamicTranslator" />
paket add DynamicTranslator --version 1.0.0
#r "nuget: DynamicTranslator, 1.0.0"
#:package DynamicTranslator@1.0.0
#addin nuget:?package=DynamicTranslator&version=1.0.0
#tool nuget:?package=DynamicTranslator&version=1.0.0
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 | Versions 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. |
-
.NETStandard 2.1
- Microsoft.AspNetCore.Mvc.Abstractions (>= 2.3.0)
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.4)
- Microsoft.Extensions.Localization (>= 9.0.4)
- Microsoft.Extensions.Localization.Abstractions (>= 9.0.4)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.4)
- Microsoft.Extensions.Options (>= 9.0.4)
- System.Text.Json (>= 9.0.4)
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 |