Aiursoft.Dotlang 9.0.8

dotnet tool install --global Aiursoft.Dotlang --version 9.0.8
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local Aiursoft.Dotlang --version 9.0.8
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=Aiursoft.Dotlang&version=9.0.8
                    
nuke :add-package Aiursoft.Dotlang --version 9.0.8
                    

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.

Installation

Requirements:

  1. .NET 9 SDK

Run the following command to install this tool:

dotnet tool install --global Aiursoft.Dotlang

Run locally

Requirements about how to run

  1. .NET 9 SDK
  2. 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 it works

  • Find all files ends with .cshtml
  • foreach cshtml file, replace all text in tag sround with @Localizer[""]
  • Call bing translate API to translate all those content
  • 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.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
9.0.8 20 21 hours ago
9.0.7 151 a month ago
9.0.6 144 a month ago
9.0.5 109 2 months ago
9.0.4 108 2 months ago
9.0.3 101 2 months ago
9.0.2 90 3 months ago
9.0.1 62 3 months ago
9.0.0 110 3 months ago
8.0.13 113 3 months ago
8.0.12 130 6 months ago
8.0.11 121 6 months ago
8.0.10 99 6 months ago
8.0.9 111 6 months ago
8.0.8 116 7 months ago
8.0.7 106 8 months ago
8.0.6 118 9 months ago
8.0.5 100 9 months ago
8.0.4 120 9 months ago
8.0.3 115 9 months ago
8.0.2 116 10 months ago
8.0.1 120 6/5/2024
8.0.0 1,135 2/19/2024
7.0.11 1,361 2/2/2024
7.0.10 1,453 1/30/2024
7.0.9 1,984 12/12/2023
7.0.8 2,030 12/12/2023
7.0.6 2,258 12/6/2023
7.0.5 2,246 12/6/2023
7.0.4 2,209 12/6/2023
7.0.3 2,074 11/12/2023
7.0.2 2,550 11/2/2023
7.0.1 2,420 11/2/2023
7.0.0 2,807 9/7/2023
6.0.2 2,958 7/20/2023
6.0.1 2,813 5/18/2023