Aiursoft.Dotlang 9.0.20

ASP.NET Core App Translator

MIT licensed Pipeline stat Test Coverage NuGet version (Aiursoft.DotLang) ManHours

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.

Installation

Requirements:

  1. .NET 9 SDK

Run the following command to install this tool:

dotnet tool install --global Aiursoft.Dotlang

Usage

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

Run locally

Requirements about how to run

  1. .NET 9 SDK
  2. Ollama.
  3. Execute dotnet run to run the app

Run in Microsoft Visual Studio

  1. Open the .sln file in the project path.
  2. Press F5.

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.

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!

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.

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 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.

This package has no dependencies.

Version Last updated
9.0.24 07/04/2025
9.0.23 06/26/2025
9.0.22 06/23/2025
9.0.21 06/23/2025
9.0.20 06/23/2025
9.0.19 06/18/2025
9.0.18 06/13/2025
9.0.17 06/12/2025
9.0.16 06/12/2025
9.0.15 06/11/2025
9.0.13 06/11/2025
9.0.12 06/07/2025
9.0.11 06/06/2025
9.0.10 06/02/2025
9.0.9 06/01/2025
9.0.8 04/10/2025
9.0.7 03/12/2025
9.0.6 06/10/2025
9.0.5 05/20/2025
9.0.4 06/12/2025
9.0.3 05/17/2025
9.0.2 05/22/2025
9.0.1 05/22/2025
9.0.0 04/19/2025
8.0.13 04/21/2025
8.0.12 04/02/2025
8.0.11 06/07/2025
8.0.10 04/25/2025
8.0.9 03/26/2025
8.0.8 04/16/2025
8.0.7 04/01/2025
8.0.6 04/03/2025
8.0.5 04/06/2025
8.0.4 03/16/2025
8.0.3 04/01/2025
8.0.2 04/10/2025
8.0.1 04/16/2025
8.0.0 06/07/2025
7.0.11 04/10/2025
7.0.10 06/07/2025
7.0.9 04/25/2025
7.0.8 04/16/2025
7.0.6 06/07/2025
7.0.5 05/04/2025
7.0.4 03/30/2025
7.0.3 04/16/2025
7.0.2 06/07/2025
7.0.1 04/16/2025
7.0.0 04/16/2025
6.0.2 04/16/2025
6.0.1 04/03/2025