Reputation: 5038
I'm trying to make an ASP.NET Core 2.0 application multi-language. I created a resource file under a folder "Resources" called "Resource.it.resx". I set its access modifier to Public and its Namespace to Resources.
After (re)building the solution I cannot see this namespace in the C# code now in the cshtml code.
Is there some other steps to do?
Upvotes: 1
Views: 1157
Reputation: 32068
There are two things you need to take into account:
Resource.resx
generates a namespace, culture-specific resources such as Resource.it.resx
does not generate a namespace. This is the intended behavior.IStringLocalizer
. I suggest you to read the fundamentals of ASP.NET Core localization in the official MSDN guide. There you will find examples for localizing strings in Controllers, Views and wherever you need them.
Upvotes: 1
Reputation: 87
First thing check if your resource namespace is visible in controller, like Resources.Resource.
I had not and in this situation I have created emtpy resource class, ex. my resources name is ServiceResources.en-US.resx, in same folder I have ServiceResources.cs empty class too.
Check if you have imported your namespace in _ViewImports.cshtml correctly, with IStringLocalizer class.
Upvotes: 1