在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):ForEvolve/ForEvolve.AspNetCore.Localization开源软件地址(OpenSource Url):https://github.com/ForEvolve/ForEvolve.AspNetCore.Localization开源编程语言(OpenSource Language):C# 100.0%开源软件介绍(OpenSource Introduction):ForEvolve.AspNetCore.LocalizationThe ForEvolve.AspNetCore.Localization package allows you to enable localization of Asp.Net Core 2.1+ applications in one line of code. Moreover, it translates Supported languages:
Supported attributes
You can also create and register your own adapters and attributes like normal. VersioningThe packages follows semantic versioning and uses Nerdbank.GitVersioning to automatically version packages based on git commits/hashes. NuGet (Release)You can: Install-Package ForEvolve.AspNetCore.Localization or dotnet add package ForEvolve.AspNetCore.Localization or take a look at https://www.nuget.org/packages/ForEvolve.AspNetCore.Localization/. CI buildsPR builds are pushed to feedz.io before getting released to NuGet, thanks to their Open Source subscription. The NuGet v3 URL is: https://f.feedz.io/forevolve/localization/nuget/index.json How to useTo enable localization for everything, including data annotation, you need to:
public void ConfigureServices(IServiceCollection services)
{
// MVC (2.1)
services
.AddMvc()
.AddForEvolveLocalization()
;
// MVC (3+)
services
.AddRazorPages() // or other part of MVC that returns an IMvcBuilder
.AddForEvolveLocalization()
;
}
public void Configure(IApplicationBuilder app)
{
// (optional)
// Adds the Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware to automatically
// set culture information for requests based on information provided by the client.
app.UseRequestLocalization();
//...
} As you can see, it took only one line of code to enable localization, and another line to automatically set the culture information for requests using
If you don't want services
.AddRazorPages() // or other part of MVC that returns an IMvcBuilder
.AddForEvolveLocalization(
enableViewLocalization: false,
enableDataAnnotationsLocalization: false
)
; Migrating to 3.0If you want to change any Asp.Net-related options, you can Configure them or implements If you built custom services.AddSingleton<ILocalizationValidationAttributeAdapter, MyAdapter>() For any other use-case that I may have forgotten, please open an issue. How to contribute a translationSince I only know French and English, I can't translate messages into more languages, so contributions are very welcome. I built a small tool to help find the culture-neutral and culture-specifics How to submit a new translation:
Since I don't speak all languages, I cannot validate those that I don't know (except maybe by using Google Translate), so it's up to you to makes things right! (or PR corrections) I will do my best to integrates PR as fast as possible. Where are the error messages located?If you look under If you want to create a culture-specific translation, example: Example:
Error messagesI modified default error messages a little to make them more linear. Sometimes it was written I am open to suggestion if you think this makes no sense. English is only my secondary language. Error messages source (if you want the original error messages): corefx/src/System.ComponentModel.Annotations/src/Resources/Strings.resx The history of the projectI created this project because I did not want to code something similar to this every single time I start a new Asp.Net Core application. I did not want to write an error message on every To be honest, I was a little disappointed to see how hard it is to localize Asp.Net Core validation attributes. This should be trivial. Don't get me wrong here; I don't want to criticize the design made by the team that built that system. I can only assume that there are some good reasons behind these design choices (technical or not). That said, the other parts of the localization pipeline of Asp.Net Core are pretty neat with How to contribute?If you have ideas, requests or find bugs, please open an issue. If you want to contributes some code, other than translating error messages, please open an issue first so you don't waste your time. For more information, please read Contributing to ForEvolve open source projects. Contributor Covenant Code of ConductAlso, please read the Contributor Covenant Code of Conduct that applies to all ForEvolve repositories. Change log3.0.0
2.2.0
2.1.0
2.0.0
Possible/Known issues
1.3.0
1.2.0
1.1.0
1.0.0
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论