I want to create console application in Microsoft Visual C# 2010 Express that will have support for a few languages: it will show messages in selected language. What is the simpliest and convenient way to make it international-ready?
Your best bet is to use assembly resource files using the project menu then add resources to your file.
To use the language specific resources in your program:
System.Resources.ResourceManager mgr = new
System.Resources.ResourceManager("MyConsoleApp.MyResource",
System.Reflection.Assembly.GetExecutingAssembly()) ;
Console.WriteLine ( mgr.GetString ("resourceName"));
Console.ReadLine ();
Use satellite assemblies as shown in this MS article:
http://msdn.microsoft.com/en-us/library/aa645513%28VS.71%29.aspx
Principally, you want to be using Resource files. This link should put you on the right path:
http://www.jelovic.com/articles/resources_in_visual_studio.htm
Once you've got resx files for your different languages, the ResourceManager
class has a GetString
method that takes a CultureInfo object, so it would return the right translation for the current culture, or the fallback value if there's no resource of that name in the translated resx file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.