0
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.

omrctlbs
  • 3
  • 1
  • Does this answer your question? [Why does not work ASP.NET Core Localization](https://stackoverflow.com/questions/49414086/why-does-not-work-asp-net-core-localization) – Mike Brind Jun 15 '23 at 11:29

1 Answers1

1

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.

IceCode
  • 1,466
  • 13
  • 22