ASP.NET Resourcemanager for reading local .resx

For my translations, I use the built-in .resx files. I want to redefine some of these translations with another .resx file that is not embedded (for example, ~ / App_Localresources / translations.en-US.resx).

The goal is that after compiling and deploying the application, the user can manually modify the .resx file to override some built-in translations.

Is there a way to use a regular ResourceManager for this? (in .NET 4)

Thanks for the tips.

+2
source share
1 answer
public class ResxResourceManager : System.Resources.ResourceManager { public ResxResourceManager(string baseName, string resourceDir) { Type[] paramTypes = new Type[] { typeof(string), typeof(string), typeof(Type) }; object[] paramValues = new object[] { baseName, resourceDir, typeof(ResXResourceSet) }; Type baseType = GetType().BaseType; ConstructorInfo ci = baseType.GetConstructor( BindingFlags.Instance | BindingFlags.NonPublic, null, paramTypes, null); ci.Invoke(this, paramValues); } protected override string GetResourceFileName(CultureInfo culture) { string resourceFileName = base.GetResourceFileName(culture); return resourceFileName.Replace(".resources", ".resx"); } } 
+3
source

Source: https://habr.com/ru/post/971757/


All Articles