我遇到了C# Razor页面本地化错误,我该如何修复它?

huangapple go评论69阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年6月15日 16:00:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/76480324.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定