Skip to content

Reconsider resource naming rules #2644

Closed
@aspnet-hello

Description

@aspnet-hello

From @ryanbrandenburg on Wednesday, March 15, 2017 11:19:44 AM

Right now if your full class name starts with the name of the assembly it will be trimmed. So for a project with assembly Project.Name.dll the class Project.Name.Startup would have the resource Startup.resx.

This seems to cause a lot of confusion and trouble (#318, #314 and many more). Previously the documentation in this area was incorrect, which likely lead to a lot of this confusion, but problems still persist and this is the most common type of issues filed on Localization.

We've already added SearchedLocation to LocalizerString to help with this, but people still seem to be having trouble so here are some of the options I've come up with.

  1. Create a "mode" on ResourceManagerStringLocalizer which will throw an exception (with a detailed error message about where it looked) when a resource isn't found instead of returning the key as a result. The idea here is that it makes it clearer when a resource isn't found rather than "hiding" that behind "the key as default".
  2. Don't do any trimming of class names. So the resource for Project.Name.Startup would always be Project.Name.Startup.resx no matter what the AssemblyName is. We could roll this out slowly by allowing fallback to the "trimmed" name for some time (or forever). The idea here is to reduce the complexity of figuring out what to name resource to the simplest possible thing, even if it means having longer resource names (or more deeply nested resource folders).

Copied from original issue: aspnet/Localization#343

Metadata

Metadata

Labels

area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templates

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions