I have a resource file strings.resx in my project that stores default English strings. For testing purpose, I created one more file strings.zh-CN.resx but the strings stored there are not real Chinese. They are just test strings that have been generated after appending some characters to the strings stored in strings.resx (main resource file). When user logs into zh-CN culture, this file helps to catch hard coded data and untranslated strings. Is it possible that I can get rid of strings.zh-CN.resx file and generate a fake resource on the fly when current thread culture is zh-CN?
Basically - are there any ways we can trick ResourceManager to return fake strings for particular cultures without having a physical .resx file?
I am using Visual Studio auto generated designer.cs file to fetch resource. I can see in designer.cs file that there is one static property for each string in .resx file. The way ResourceManager is initialized in designer.cs is as under.
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("xxx.xxx.Strings", typeof(Strings).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
This is the way static property is added by auto generated code.
/// <summary>
/// Looks up a localized string similar to Absolute.
/// </summary>
public static string Absolute {
get {
return ResourceManager.GetString("Absolute", resourceCulture);
}
}
I am looking for extension points in this retrieval. if possible I want to hook in my own custom ResourceManager (or something else I am not sure) and return a fake pseudo string when culture is zh-CN. Main purpose is I do not want to be generating a fake physical resource file just for testing purpose.