6

I have been able to successfully run an asp.net mvc6 localization sample app however all the .resx files are placed in one "resources" folder.

If you have a look at this sample application You will notice that all the resources are placed in the root directory folder: "Resources" and it is referenced in the Startup.cs file like this:

 services
            .AddMvc()
            .AddViewLocalization(options => options.ResourcesPath = "Resources")
            .AddDataAnnotationsLocalization();

The current application I am working on has multiple areas and ideally I would like to better organize these .resx files. Otherwise it's going to get very messy.

Is this even possible yet in MVC6?

Cool Breeze
  • 1,289
  • 11
  • 34

2 Answers2

1

One possible thing you can do is to create seperate folders per area in your resource route folder. In those "area folders" you can create several specific resource files.

Seems quite manageable to me.

For ex.

Resources

  • CatalogArea
    • ProductTranslations.resx
    • CategoryTranslations.resx
  • SupportArea
    • KnowledgeBaseTranslations.resx
Tom B.
  • 2,892
  • 3
  • 13
  • 34
1

You can store resource (and not just resource files - for example I store my translations in json file) where ever you want. You just have to override:

  • IStringLocalizer
  • IStringLocalizerFactory
Dawid Rutkowski
  • 2,658
  • 1
  • 29
  • 36
  • Thank you for the contribution. However do you have a small example? or point me to a page that has an example? – Cool Breeze Jan 27 '16 at 00:34
  • Take a look here: http://www.leonardlabat.com/2015/11/28/custom-json-localization-with-asp-net-5/. You'll find there all the information's required to write your custom localization. – Dawid Rutkowski Jan 27 '16 at 11:11
  • Looks good and I will look into these at another time. However this just seems like overkill. It used to be so easy in asp.net MVC5. Surely there is an equivalent in MVC6? – Cool Breeze Jan 27 '16 at 11:31