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?
+1
A:
Use satellite assemblies as shown in this MS article:
http://msdn.microsoft.com/en-us/library/aa645513%28VS.71%29.aspx
ho1
2010-05-28 07:54:01
Where can I download this sample?
Semyon Perepelitsa
2010-05-28 11:20:43
ho1
2010-05-28 11:39:36
A:
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.
Russ C
2010-05-28 07:54:28
+2
A:
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 ();
Laramie
2010-05-28 07:57:45
Now it loads my system language. How can I change it to check other languages?
Semyon Perepelitsa
2010-05-28 11:27:33
You can set the culture of the current thread by usingThread.CurrentThread.CurrentUICulture = new CultureInfo("en-US")where en-US is the RFC3066 code.This link has a full tutorial to helphttp://www.codeguru.com/vb/gen/vb_misc/multi-languagesupport/article.php/c5601/
Laramie
2010-05-28 19:56:47