Aiursoft.Dotlang 8.0.12
ASP.NET Core App Translator
This app helps you generate translated .cshtml
files and resources
files.
How to install
Run the following command to install this tool:
dotnet tool install --global Aiursoft.Dotlang
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 theResources
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.
How to run locally
Build:
dotnet pack
Install:
dotnet tool install --global --add-source ./nupkg dotlang
Run:
# In your project folder
$ dotlang
Uninstall:
dotnet tool uninstall -g dotlang
Before running the translator
- Follow the document here ASP.NET Core Localization
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.
This package has no dependencies.
Version | Downloads | Last updated |
---|---|---|
9.0.2 | 0 | 01/16/2025 |
9.0.1 | 0 | 01/15/2025 |
9.0.0 | 0 | 01/02/2025 |
8.0.13 | 0 | 01/01/2025 |
8.0.12 | 4 | 10/10/2024 |
8.0.11 | 0 | 10/09/2024 |
8.0.10 | 2 | 10/07/2024 |
8.0.9 | 0 | 10/05/2024 |
8.0.8 | 6 | 09/07/2024 |
8.0.7 | 4 | 07/31/2024 |
8.0.6 | 6 | 07/12/2024 |
8.0.5 | 5 | 07/10/2024 |
8.0.4 | 5 | 06/29/2024 |
8.0.3 | 4 | 06/28/2024 |
8.0.2 | 4 | 06/18/2024 |
8.0.1 | 5 | 06/05/2024 |
8.0.0 | 16 | 03/26/2024 |
7.0.11 | 6 | 03/31/2024 |
7.0.10 | 8 | 04/25/2024 |
7.0.9 | 7 | 04/25/2024 |
7.0.8 | 7 | 04/03/2024 |
7.0.6 | 9 | 04/04/2024 |
7.0.5 | 6 | 04/25/2024 |
7.0.4 | 5 | 03/29/2024 |
7.0.3 | 10 | 04/21/2024 |
7.0.2 | 7 | 04/25/2024 |
7.0.1 | 4 | 04/25/2024 |
7.0.0 | 8 | 04/25/2024 |
6.0.2 | 5 | 04/03/2024 |
6.0.1 | 9 | 04/02/2024 |