Asp.net localization - override which resx file the page will use

Trying to sort matching topics and localize ... what I'm doing:

Localization A.aspx creates:

  • App_Localresources \ a.aspx.resx
  • App_Localresources \ a.aspx.resx.fr ...

However, I want to add additional parameters. I want to have:

  • App_Localresources \ a_theme1.aspx.resx
  • App_Localresources \ a_theme1.aspx.resx.fr
  • App_Localresources \ a_theme2.aspx.resx
  • App_Localresources \ a_theme2.aspx.resx.fr

So, if I am in Theme1, I want to use a resource set for theme 1.

Is there a way that I can override which resx file A.aspx will use when loading?

those. when it tries to download a.aspx.resx.fr file, I want to replace it with a_theme1.resx.fr

Thanks so much for any ideas! :)

+4
source share
1 answer

Take a look here:

ResourceManager.GetResourceFileName Method

This method uses the name CultureInfo property as part of the file name for all cultures other than the culture invariant. This method does not look like the manifest of the meeting or tap the disk, and is used only to build what resource file name (suitable for going to the ResourceReader constructor) or manifest resource blob name should be.

A derived class may override this search method with a different extension, such as ".ResX," or a completely different scheme for naming files.

I think you want to do something like this:

public class ResxResourceManager : ResourceManager { protected override string GetResourceFileName( System.Globalization.CultureInfo culture) { return base.GetResourceFileName(culture); } public string GetResxFileName(System.Globalization.CultureInfo culture) { return GetResourceFileName(culture).Replace(".resources", ".resx"); } } 

More on this:

Create a custom resource provider

Under the hood of BuildManager and Resource Processing

+1
source

All Articles