英文:
I'm getting C# Razor Page Localization error how do I fix it?
问题
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddLocalization(options => options.ResourcesPath = "Resources");
// Add services to the container.
builder.Services.AddRazorPages()
.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
.AddDataAnnotationsLocalization();
英文:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddLocalization(options => options.ResourcesPath = "Resources");
// Add services to the container.
builder.Services.AddRazorPages();
*** .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
.AddDataAnnotationsLocalization();
//------------------------------------------
https://www.youtube.com/watch?v=rRpLIytLtbQ
Hello, I am making a website using c# razor page. I was doing localization by looking at the video below. But where I marked "***" I get the following error. Why do you think it might?
Eror:CS0103 The name 'AddViewLocalization' does not exist in the current context
Same Line :CS1022 Type or namespace definition, or end-of-file expected
The website was considering adding language support. But it was not successful.
答案1
得分: 1
以下是翻译好的部分:
"builder.Services.AddRazorPages()
.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
.AddDataAnnotationsLocalization();"
英文:
The code should be like the following:
builder.Services.AddRazorPages()
.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
.AddDataAnnotationsLocalization();
Note that I have removed the semicolon ;
at the end of code line.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论