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?
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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.