How can I get localized text dynamically in a Windows 8 phone? I find out that if I want text, I can do this:
AppResources.ERR_VERSION_NOT_SUPPORTED
But suppose I get my keyword from the server. I am returning a string
ERR_VERSION_NOT_SUPPORTED
Now I would like to get the correct text from AppResources .
I tried the following:
string methodName = "ERR_VERSION_NOT_SUPPORTED"; AppResources res = new AppResources();
problem in this example: MethodInfo mi null ...
Does anyone have any idea?
EDIT:
Thanks to everyone for the quick answers. I'm actually quite new to C #, and I always mix Properties due to the syntax of getters and seters.
my AppResources looks like this:
/// <summary> /// A strongly-typed resource class, for looking up localized strings, etc. /// </summary> // This class was auto-generated by the StronglyTypedResourceBuilder // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class AppResources { ... /// <summary> /// Looks up a localized string similar to This version is not supported anymore. Please update to the new version.. /// </summary> public static string ERR_VERSION_NOT_SUPPORTED { get { return ResourceManager.GetString("ERR_VERSION_NOT_SUPPORTED", resourceCulture); } } }
also trying to get a dynamic property that doesn't work ... and I realized that I could use this method directly:
string message = AppResources.ResourceManager.GetString("ERR_VERSION_NOT_SUPPORTED", AppResources.Culture);
Greetings to all
schurtertom
source share