views:

71

answers:

3

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
Where can I download this sample?
Semyon Perepelitsa
ho1
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
+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
Now it loads my system language. How can I change it to check other languages?
Semyon Perepelitsa
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