-
Notifications
You must be signed in to change notification settings - Fork 65
Localization not working after changing rootnamespace #340
Comments
I'm not sure. It worked before updating the project format to the new one in VS 2017. |
I'm still surprising why you changed the default namespace for sample repo? |
Just to test if I could replicate the problem |
IMHO changing this absolutely will affect the generated resource files, so that's why you should care about the namespaces. I saw many issues in the past raised by namespace conflict, so that's why I mentioned the issue #296 in my first comment |
When having trouble with resource discovery make sure you've read the localization docs, especially https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization#resource-file-naming. To sum up, there are two things you must know before naming a resource, first is the name of the assembly for your project. This is decided by a lot of different factors (name of Once you know both of these things you can create your resource. You must name your resource the full name of the class, but trim the assembly name from the front if it's there. So in the project If you're still having trouble after double checking these things please upload a sample which reproduces your problem to GitHub for us to review and debug against. |
I'm able to reproduce the issue after modifying the default namespace This will let all the resource files to use the newly |
Maybe I'm doing something wrong.. |
Changing the RootNamspace absolutely will cause the bug, but still wondering we need change it?!! @Eilon can we consider this as bug? |
We need to change it for example when a company has a structured enterprise path on namespace, for example An other example is when you have a complex solution with modules, where you want to put modules on other sub namespaces of the original project. |
Good point @tmm360, IMHO this absolutely a bug |
https://github.com/mattiaz9/LocalizationSample/blob/master/LocalizationSample/Startup.cs#L13 @ryanbrandenburg this is the same behavior of the issue #296 that @dougbu mentioned long time back, expect that caused by using invalid as a C# identifier, while this cause by changing the |
For the sake of reproducing the issue, I created the sample too: Actually, localization is working, but not based on RESX files in this case. If you localize like: *.EN.cshtml, this still works. |
This issue should really be addressed before 2.0 goes life imho or another year may pass. It's an absolutely common practice in n-layer architecture that assembly name do not equal the default namespace. |
I have a very localized netcoreapp2.0 (web) but now my executing assembly has a name like: I'd be ready to add an attribute to my classes with a property pointing to the right namespace for localization. But this would not work for razor views... |
@ryanbrandenburg, let's meet to discuss the solution. |
@mattiaz9 we are discussing possible permanent solutions to your issue, but I wanted to let you know that one possible temporary solution to your problem is to add the correct |
@ryanbrandenburg: Can you post an example/code? |
This issue was moved to dotnet/aspnetcore#2645 |
If you specify a default namespace different from the assembly name the localization doesn't work anymore.
The text was updated successfully, but these errors were encountered: