Reputation: 2983
I try to create a CMS for which I have to set the Culture Info depending on the language selection for a specific page. The only way to set the current language is the following:
System.Globalization.CultureInfo.CurrentCulture = new System.Globalization.CultureInfo("el-GR");
System.Globalization.CultureInfo.CurrentUICulture = new System.Globalization.CultureInfo("el-GR");
I tried to use these lines in the following locations:
The best solution to my problem would be to set the culture in the action (I have one action which handles all the CMS requests) but in case that this is not possible it would be helpful to find a way to set the culture in the _Layout.cshtml file.
Upvotes: 0
Views: 296
Reputation: 1675
Please check this link Globalization and localization in ASP.NET Core.
there many ways to do that
Implement a strategy to select the language/culture for each request
- Localization middleware
- QueryStringRequestCultureProvider
- The Accept-Language HTTP header
- Use a custom provider
Upvotes: 2