Skip to content
This repository was archived by the owner on Nov 29, 2018. It is now read-only.

StringLocalizerFactory assumes that the default namespace is the same as the application name when resourcePath is specified #244

Closed
pranavkm opened this issue May 16, 2016 · 7 comments
Assignees

Comments

@pranavkm
Copy link
Contributor

pranavkm commented May 16, 2016

Steps:

  1. Create an application named App1
  2. Add .AddViewLocalization(options => options.ResourcesPath = "custom-dir") to Startup
  3. Add a resource under custom-dir named Controllers.HomeController.resx and verify that the IHtmlLocalizer<HomeController> correctly works for App1.Controllers.HomeController.
  4. Change the namespace for the controller to App2.Controllers.HomeController and see it fail to locate it.

Kinda obscure scenario I ran into when I tried copying the Controller from release verification to a different app.

Expected:
Perhaps an option to to specify the default namespace and for the resource to continue to be located.

@hishamco
Copy link
Contributor

I think it's duplicate or related to the issue #157

@Eilon Eilon added this to the 1.1.0 milestone Jul 7, 2016
@Eilon
Copy link
Contributor

Eilon commented Jul 7, 2016

@ryanbrandenburg please see if this is a dup of the other bug.

@ryanbrandenburg
Copy link
Contributor

This is a documented edge case. If you're resource isn't in the main namespace for your project you must specify the entire namespace. So from your example Controllers.HomeController.resx would become App2.Controllers.HomeController.resx. We allow the base namespace to be left off the to prevent excessively long names or nested folders, but to prevent collisions you must specify the namespace of anything else.

How do you feel about that behavior? It's not my favorite thing, but I can't come up with any better solutions, so I'm open to input.

@pranavkm
Copy link
Contributor Author

pranavkm commented Jul 8, 2016

If you're resource isn't in the main namespace for your project you must specify the entire namespace.

I think in this case it was the inverse. The resource was in the base namespace, the controller (TType for IHtmlLocalizer<TType> ) wasn't. I think I might've spent less figuring out this issue if #258 is addressed.

@Eilon
Copy link
Contributor

Eilon commented Jul 8, 2016

@ryanbrandenburg can you discuss with @DamianEdwards if necessary as well?

@ryanbrandenburg
Copy link
Contributor

Sorry @pranavkm I was being confusing, I meant

If you're .cs file isn't in the main namespace for your project you must specify the entire namespace on the resource.

I talked with @DamianEdwards in person, he agrees with me that this is expected behavior.

@ryanbrandenburg
Copy link
Contributor

Since nobody seems to be objecting I'll close this one out, feel free to re-open if there's new or missing info.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants