Aiursoft.Dotlang.AspNetTranslate 10.0.100

dotnet add package Aiursoft.Dotlang.AspNetTranslate --version 10.0.100
                    
NuGet\Install-Package Aiursoft.Dotlang.AspNetTranslate -Version 10.0.100
                    
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="Aiursoft.Dotlang.AspNetTranslate" Version="10.0.100" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Aiursoft.Dotlang.AspNetTranslate" Version="10.0.100" />
                    
Directory.Packages.props
<PackageReference Include="Aiursoft.Dotlang.AspNetTranslate" />
                    
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 Aiursoft.Dotlang.AspNetTranslate --version 10.0.100
                    
#r "nuget: Aiursoft.Dotlang.AspNetTranslate, 10.0.100"
                    
#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 Aiursoft.Dotlang.AspNetTranslate@10.0.100
                    
#: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=Aiursoft.Dotlang.AspNetTranslate&version=10.0.100
                    
Install as a Cake Addin
#tool nuget:?package=Aiursoft.Dotlang.AspNetTranslate&version=10.0.100
                    
Install as a Cake Tool

Aiursoft Dotlang

<a name="aspnet-core-app-translator"></a> MIT licensed Pipeline stat Test Coverage S360 compliance NuGet version (Aiursoft.DotLang) Man hours

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.

Overview

What is Dotlang?

Extract and translate ASP.NET Core localization resources, translate folders and reuse the translation engines from .NET applications.

Installation

Install the CLI with the .NET 10 SDK:

dotnet tool install --global Aiursoft.Dotlang

Update an existing installation:

dotnet tool update --global Aiursoft.Dotlang

Remove the CLI:

dotnet tool uninstall --global Aiursoft.Dotlang

Usage

Run the command to see available options:

dotlang --help

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.

Workflow Overview

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.

<a name="use-as-a-simple-translator"></a>

Use as a simple translator

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.

<a name="auto-generate-view-injections"></a>

Auto-generate View Injections

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 .

<a name="use-as-a-library"></a>

Use as a library

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);

<a name="translate-plain-text"></a> Translate plain text

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); // 你好,世界!

<a name="advanced-usage-with-translateentry"></a> Advanced Usage with TranslateEntry

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);

<a name="how-does-this-work"></a>

How does this work?

  • Find all files ends with .cshtml.
  • foreach cshtml file, replace all text in tag surrounded with @Localizer[""] with the content inside.
  • Call ollama to translate all the content. (The entire file will be sent to ollama to make sure AI understands the context.)
  • Save the translated file as 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.

<a name="caution"></a>

Caution

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.

Configuration

Configuration is supplied through command-line options and, for library consumers, TranslateOptions. The complete existing command examples, folder options and service-registration sample are retained in Usage.

Use dotlang --help and dotlang <command> --help for current options. Translation commands require a model, endpoint and credential as documented for each command; concurrent requests are controlled by the applicable command options. Configure an endpoint that implements the API expected by that command, and keep real provider credentials out of committed files.

Install and configure Ollama when using an Ollama endpoint. A configured compatible remote provider is used directly; a local model server is not supplied by installing the CLI.

<a name="before-running-the-translator"></a> Before running the translator

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!

Development

Install the .NET 10 SDK.

From the repository root, restore and build:

dotnet restore Aiursoft.Dotlang.sln
dotnet build Aiursoft.Dotlang.sln --no-restore

<a name="run-locally"></a> <a name="local-run"></a> Run the tool from source, with the prerequisites and configuration above:

dotnet run --project src/Aiursoft.Dotlang/Aiursoft.Dotlang.csproj -- --help

<a name="run-in-microsoft-visual-studio"></a> In Microsoft Visual Studio, open Aiursoft.Dotlang.sln, select Aiursoft.Dotlang as the startup project and press F5. Configure the arguments and environment for the task you want to run.

Run the existing tests:

dotnet test Aiursoft.Dotlang.sln --no-restore

How to contribute

There are many ways to contribute to the project: logging bugs, submitting pull requests, reporting issues, and creating suggestions.

Even if you have 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.

License

Licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.

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
10.0.100 51 11/19/2026
10.0.99 83 11/16/2026
10.0.98 91 11/16/2026
10.0.97 99 11/14/2026
10.0.96 96 11/12/2026
10.0.95 100 11/11/2026
10.0.94 91 11/11/2026
10.0.93 93 11/11/2026
10.0.92 93 11/9/2026
10.0.91 124 11/6/2026
10.0.90 106 11/5/2026
10.0.89 100 11/3/2026
10.0.88 113 10/31/2026
10.0.87 112 10/29/2026
10.0.86 112 10/26/2026
10.0.85 109 10/26/2026
10.0.84 98 10/25/2026
10.0.83 114 10/24/2026
10.0.82 115 10/23/2026
10.0.81 109 10/20/2026
Loading failed