How to make a multilingual c # console application?

I want to create a console application in Microsoft Visual C # 2010 Express that will support several languages: it displays messages in the selected language. What is the easiest and most convenient way to make it ready for international trade?

+5
source share
3 answers

It is best to use assembly resource files using the project menu, and then add resources to your file.

To use language 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 ();
+6
source

Use satellite assemblies as shown in this MS article:

http://msdn.microsoft.com/en-us/library/aa645513%28VS.71%29.aspx

+1

, . :

http://www.jelovic.com/articles/resources_in_visual_studio.htm

After you have resx files for different languages, the class ResourceManagerhas a method GetStringthat accepts a CultureInfo object, so it will return the correct translation of the current culture or the backup value if there is no resource of this name in the translation of the resx file.

0
source

All Articles