Comments on: Localization in ASP.NET Core https://code-maze.com/aspnetcore-localization/ Learn. Code. Succeed. Wed, 31 Jan 2024 14:38:10 +0000 hourly 1 https://wordpress.org/?v=6.7.5 By: Kadir https://code-maze.com/aspnetcore-localization/#comment-8402 Thu, 15 Jun 2023 06:39:09 +0000 https://drafts.code-maze.com/?p=75501#comment-8402 Hi,
I’m using cookie based localization. When I change the culture, IViewLocalizer is working but Annotation errors stays the starting culture. I need to rerun the application. How can I solve this?

]]>
By: Jaime https://code-maze.com/aspnetcore-localization/#comment-7147 Thu, 15 Dec 2022 13:30:58 +0000 https://drafts.code-maze.com/?p=75501#comment-7147 Hello…. this is perfect for a mulilingual site, however, I have developed a site that is to be used only by Spanish speaking users. How can the default ASP.NET core messages be shown in Spanish? For example, if user is changing password and he uses one that not meets the complexity requirements, these errors are shown: “Passwords must have at least one non alphanumeric character, Passwords must have at least one lowercase (‘a’-‘z’), Passwords must have at least one uppercase (‘A’-‘Z’).”

When I developed in .NET Framework, those kind of messages appear correctly in Spanish. How can I achieve the same in .NET Core 6?

Thanks
Jaime

]]>
By: Phil Broderick https://code-maze.com/aspnetcore-localization/#comment-6897 Wed, 09 Nov 2022 16:36:51 +0000 https://drafts.code-maze.com/?p=75501#comment-6897 In reply to Branislav Petrović.

Great timing! Very interesting read – I’ll have to have a play about with it. Thanks for the link.

]]>
By: Branislav Petrović https://code-maze.com/aspnetcore-localization/#comment-6888 Tue, 08 Nov 2022 10:51:10 +0000 https://drafts.code-maze.com/?p=75501#comment-6888 In reply to Phil Broderick.

Hi Phil, thanks for the suggested links. Jürgen Gutsch recently wrote article in which he explained one solution to this problem – http://asp.net-hacker.rocks/2022/10/25/aspnetcore-globalization.html

]]>
By: Phil Broderick https://code-maze.com/aspnetcore-localization/#comment-6887 Tue, 08 Nov 2022 10:23:41 +0000 https://drafts.code-maze.com/?p=75501#comment-6887 In reply to Branislav Petrović.

Hi Branislav,

Glad you enjoyed the article! Unfortunately, setting the culture code in the URL instead of a query string would require quite a bit of extra work. You could add a custom route template that includes the culture, but this would require you to add a parameter to each endpoint to retrieve and set the culture.

I haven’t implemented this myself, but I did find some examples of how you could do it:
https://stackoverflow.com/questions/73004331/include-culture-in-razor-page-url-custom-routes
https://stackoverflow.com/questions/54149233/set-current-culture-in-url-when-application-starts-or-navigates-to-home-page

]]>
By: Phil Broderick https://code-maze.com/aspnetcore-localization/#comment-6886 Tue, 08 Nov 2022 10:05:24 +0000 https://drafts.code-maze.com/?p=75501#comment-6886 In reply to Carlo Štefanac.

Hi Carlo. Glad you liked the article and great to hear you got sorted with your issue!

As we are using the folder organization for naming our resource files, we need to follow the same for partial views, such as _Layout.cshtml.

]]>
By: Carlo Štefanac https://code-maze.com/aspnetcore-localization/#comment-6871 Wed, 02 Nov 2022 14:03:10 +0000 https://drafts.code-maze.com/?p=75501#comment-6871 In reply to Carlo Štefanac.

My _Layout.en.resx was not under Resources\Views\Shared. Now it’s working !

]]>
By: Carlo Štefanac https://code-maze.com/aspnetcore-localization/#comment-6870 Wed, 02 Nov 2022 13:35:56 +0000 https://drafts.code-maze.com/?p=75501#comment-6870 Hi,

thanks for great tutorial ! How can I translate strings in layout html ? Menu for example?

]]>
By: Branislav Petrović https://code-maze.com/aspnetcore-localization/#comment-6807 Fri, 21 Oct 2022 13:36:33 +0000 https://drafts.code-maze.com/?p=75501#comment-6807 Great article! Nice overview of different ASP.NET Core interfaces to provide localization in different files. What about providing culture code in URL instead of query string (e.g. /en/Localization/LocalizedView), how would you achieve that?

Thanks!

]]>
By: Phil Broderick https://code-maze.com/aspnetcore-localization/#comment-6782 Wed, 19 Oct 2022 08:35:29 +0000 https://drafts.code-maze.com/?p=75501#comment-6782 In reply to Emmanuel Larrieux.

Hey Emmanuel. Glad you enjoyed the article!

You are indeed correct that the default template does not include controllers – that was my mistake. We will look to update the article to reflect this.

Do you mean the LocalizationController was missing the AspNetCore.Mvc.Localization namespace as a using statement, or there was no project namespace defined? If it is the latter, we usually avoid adding this filler code in our snippets, but as always you can find the full source code on our GitHub: https://github.com/CodeMazeBlog/CodeMazeGuides/tree/main/aspnetcore-features/Localization

]]>