![]() |
VOOZH | about |
dotnet add package Aiursoft.Dotlang.AspNetTranslate --version 10.0.45
NuGet\Install-Package Aiursoft.Dotlang.AspNetTranslate -Version 10.0.45
<PackageReference Include="Aiursoft.Dotlang.AspNetTranslate" Version="10.0.45" />
<PackageVersion Include="Aiursoft.Dotlang.AspNetTranslate" Version="10.0.45" />Directory.Packages.props
<PackageReference Include="Aiursoft.Dotlang.AspNetTranslate" />Project file
paket add Aiursoft.Dotlang.AspNetTranslate --version 10.0.45
#r "nuget: Aiursoft.Dotlang.AspNetTranslate, 10.0.45"
#:package Aiursoft.Dotlang.AspNetTranslate@10.0.45
#addin nuget:?package=Aiursoft.Dotlang.AspNetTranslate&version=10.0.45Install as a Cake Addin
#tool nuget:?package=Aiursoft.Dotlang.AspNetTranslate&version=10.0.45Install as a Cake Tool
👁 MIT licensed
👁 NuGet version (Aiursoft.DotLang)
This app helps you generate translated .cshtml files and resources files. Based on the Ollama AI model, it translates the content inside @Localizer[""] tags in your ASP.NET Core project.
Requirements:
Run the following command to install this tool:
dotnet tool install --global Aiursoft.Dotlang
After getting the binary, run it directly in the terminal.
dotlang translate-aspnet --path ~/Code --instance http://ollama:11434/api/chat --model "qwen:32b" --token "your-ollama-token"
Description:
The command to start translation on an ASP.NET Core project.
Usage:
dotlang translate-aspnet [options]
Options:
-v, --verbose Show detailed log
-d, --dry-run Preview changes without actually making them
-p, --path <path> (REQUIRED) Path of the videos to be parsed.
-l, --languages <languages> (REQUIRED) The target languages code. Connect with ','. For example: zh_CN,en_US,ja_JP [default:
zh-CN,zh-TW,zh-HK,ja-JP,ko-KR,vi-VN,th-TH,de-DE,fr-FR,es-ES,ru-RU,it-IT,pt-PT,pt-BR,ar-SA,nl-NL,sv-SE,pl-PL,tr-TR]
--instance <instance> (REQUIRED) The Ollama instance to use.
--model <model> (REQUIRED) The Ollama model to use.
--token <token> (REQUIRED) The Ollama token to use.
-?, -h, --help Show help and usage information
For example, if you want to localize entire project with deepseek, you can run:
DEEPSEEK_API_KEY="sk-aaaaaaaa"
dotlang auto-generate-view-injections-for-aiursoft-template --path .
dotlang generate-resx-csharp --path . --model "deepseek-chat" --token $DEEPSEEK_API_KEY --instance "https://api.deepseek.com/chat/completions" -c 8
dotlang generate-resx-view --path . --model "deepseek-chat" --token $DEEPSEEK_API_KEY --instance "https://api.deepseek.com/chat/completions" -c 8
dotlang generate-resx-annotations --path . --model "deepseek-chat" --token $DEEPSEEK_API_KEY --instance "https://api.deepseek.com/chat/completions" -c 8
For example, if you want to localize entire project with Aiursoft Ollama server, you can run:
OLLAMA_API_KEY="CONFIDENTIAL"
dotlang auto-generate-view-injections-for-aiursoft-template --path .
dotlang generate-resx-csharp --path . --model "qwen3.5:27b-q8_0" --token $OLLAMA_API_KEY --instance "https://ollama.aiursoft.com/api/chat/completions" -c 8
dotlang generate-resx-view --path . --model "qwen3.5:27b-q8_0" --token $OLLAMA_API_KEY --instance "https://ollama.aiursoft.com/api/chat/completions" -c 8
dotlang generate-resx-annotations --path . --model "qwen3.5:27b-q8_0" --token $OLLAMA_API_KEY --instance "https://ollama.aiursoft.com/api/chat/completions" -c 8
Will help you generate .resx files for all the .cshtml files in the current folder.
| Step | Command | Purpose |
|---|---|---|
| 1 | auto-generate-view-injections |
Scans all Controllers for [RenderInNavBar] attributes and ViewModel strings, then injects them into the ViewModelArgsInjector._useless_for_localizer() placeholder method so that dotlang can subsequently detect these keys. |
| 2 | generate-resx-csharp |
Scans .cs files for localizer["..."] calls, translates them into all target languages using the Ollama model, and writes results to Resources/Services/*.{locale}.resx. |
| 3 | generate-resx-view |
Scans .cshtml files for @Localizer["..."] calls, translates them, and writes results to Resources/Views/**/*.{locale}.resx. |
| 4 | generate-resx-annotations |
Scans strings in [Display], [Required], and other DataAnnotation attributes, then translates and writes them to the appropriate resource files. |
| 5 | auto-dedup-resx-keys |
Removes duplicate keys from all .resx files. |
This tool can also be used to simply translate a folder of files from one language to another.
dotlang folder-translate --source "./src" --destination "./dist" --language "zh-CN" --extensions "txt" --extensions "md" --recursive --model "qwen:32b" --token "your-ollama-token" --instance "http://ollama:11434/api/chat"
Options:
-s, --source (REQUIRED): Path of the folder to translate files.-d, --destination (REQUIRED): Path of the folder to save translated files.-l, --language (REQUIRED): The target language code.-r, --recursive: Recursively search for files in subdirectories.-e, --extensions: Extensions of files to translate. Can be used multiple times. Default is html.--instance: The Ollama instance to use.--model: The Ollama model to use.--token: The Ollama token to use.-k, --skip-existing-files: Skip existing files.This command scans your project for localizable strings in Controllers and ViewModels, specifically looking for:
[RenderInNavBar] attributes (properties: NavGroupName, CascadedLinksGroupName, LinkText)PageTitle assignments in ViewModels (e.g., PageTitle = "Dashboard")It then injects these strings into a ViewModelArgsInjector service to ensure they can be picked up by the localizer.
dotlang auto-generate-view-injections-for-aiursoft-template --path .
You can also use the core logic as a library in your own project.
First, install the package:
dotnet add package Aiursoft.Dotlang.AspNetTranslate
Then, register the services in your IServiceCollection:
using Aiursoft.Dotlang.AspNetTranslate;
using Aiursoft.Dotlang.Shared;
using Aiursoft.Canon;
using Aiursoft.GptClient;
// ...
services.AddLogging();
services.AddHttpClient();
services.AddMemoryCache();
services.AddTaskCanon();
services.AddGptClient();
services.AddScoped<MarkdownShredder>();
services.AddScoped<OllamaBasedTranslatorEngine>();
services.AddScoped<CachedTranslateEngine>();
services.AddScoped<FolderFilesTranslateEngine>();
services.AddScoped<TranslateEntry>();
// Add necessary specialized services for TranslateEntry
services.AddScoped<DataAnnotationKeyExtractor>();
services.AddScoped<CshtmlLocalizer>();
services.AddScoped<CSharpKeyExtractor>();
services.AddScoped<ViewMetadataExtractor>();
services.AddTransient<DocumentAnalyser>();
new StartUp().ConfigureServices(services);
services.Configure<TranslateOptions>(options =>
{
options.OllamaInstance = "https://ollama.example.com/api/chat/completions";
options.OllamaModel = "qwen3:30b";
options.OllamaToken = "your-token";
});
Finally, you can use TranslateEntry to perform translation tasks:
var entry = serviceProvider.GetRequiredService<TranslateEntry>();
Or use FolderFilesTranslateEngine for simple file translation:
var folderEngine = serviceProvider.GetRequiredService<FolderFilesTranslateEngine>();
await folderEngine.TranslateAsync(
sourceFolder: "./src",
destinationFolder: "./dist",
language: "zh-CN",
recursive: true,
extensions: [".txt", ".md"],
skipExistingFiles: false);
You can also use the OllamaBasedTranslatorEngine to translate plain text strings directly.
var translator = serviceProvider.GetRequiredService<OllamaBasedTranslatorEngine>();
var englishText = "Hello, world!";
var chineseText = await translator.TranslateAsync(englishText, "zh-CN");
Console.WriteLine(chineseText); // 你好,世界!
var entry = serviceProvider.GetRequiredService<TranslateEntry>();
// Localize all .cshtml files in a project
await entry.StartLocalizeContentInCsHtmlAsync(
path: "./MyProject",
langs: ["zh-CN", "ja-JP"],
takeAction: true,
concurentRequests: 8);
// Localize all .cs files
await entry.StartLocalizeContentInCSharpAsync(path, langs, true, 8);
// Localize DataAnnotations
await entry.StartLocalizeDataAnnotationsAsync(path, langs, true, 8);
// Wrap plain text with @Localizer[""]
await entry.StartWrapWithLocalizerAsync(path, true);
Requirements about how to run
dotnet run to run the app.sln file in the project path.F5..cshtml.cshtml file, replace all text in tag surrounded with @Localizer[""] with the content inside.Resource file in the Resources folder.The Core Translator won't override any existing translation nor resources files. If your content was already surrounded with @Localizer[""], we won't touch it.
Use the following code to register the localizer service:
// In StartUp.cs ConfigureServices method:
services.AddLocalization(options => options.ResourcesPath = "Resources");
services.AddMvc()
.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
.AddDataAnnotationsLocalization();
Use the following code to add localizer middleware:
// In StartUp.cs Configure method
var SupportedCultures = new CultureInfo[]
{
new CultureInfo("en"),
new CultureInfo("zh")
};
app.UseRequestLocalization(new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture(defaultLanguage),
SupportedCultures = SupportedCultures,
SupportedUICultures = SupportedCultures
});
Use the following code to inject localizer:
@using Microsoft.AspNetCore.Mvc.Localization
@inject IViewLocalizer Localizer
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
Now run this app!
Running this under your project folder may ruin your project! It may change your cshtml! Do run git commit under your project before running this app.
There are many ways to contribute to the project: logging bugs, submitting pull requests, reporting issues, and creating suggestions.
Even if you with push rights on the repository, you should create a personal fork and create feature branches there when you need them. This keeps the main repository clean and your workflow cruft out of sight.
We're also interested in your feedback on the future of this project. You can submit a suggestion or feature request through the issue tracker. To make this process more effective, we're asking that these include more information to help define them more clearly.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.45 | 93 | 6/13/2026 |
| 10.0.44 | 91 | 6/10/2026 |
| 10.0.43 | 89 | 6/10/2026 |
| 10.0.42 | 104 | 6/6/2026 |
| 10.0.41 | 107 | 5/27/2026 |
| 10.0.40 | 106 | 5/15/2026 |
| 10.0.39 | 103 | 5/13/2026 |
| 10.0.38 | 96 | 5/13/2026 |
| 10.0.37 | 113 | 4/22/2026 |
| 10.0.36 | 126 | 4/15/2026 |
| 10.0.35 | 109 | 4/15/2026 |
| 10.0.34 | 115 | 4/6/2026 |
| 10.0.33 | 122 | 3/18/2026 |
| 10.0.32 | 105 | 3/18/2026 |
| 10.0.31 | 107 | 3/18/2026 |
| 10.0.30 | 109 | 3/18/2026 |
| 10.0.29 | 125 | 3/14/2026 |
| 10.0.28 | 113 | 3/9/2026 |
| 10.0.27 | 106 | 3/9/2026 |
| 10.0.26 | 105 | 3/8/2026 |