Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Localization of windows form c#

Tags:

c#

i have seen people localize their form using resource. put text data in resource file and show those text data in windows form apps fetch from resource file. but my requirement is different that when my apps will on any pc and that pc language is set Germany or french then all control caption of my apps will be shown in that language. how could i do this....what code i need to write. i need to write very minimum code to implement it.

static int Main( string[] argv )
{
CultureInfo ci = CultureInfo.InstalledUICulture ;

Console.WriteLine("Default Language Info:" ) ;
Console.WriteLine("* Name: {0}"                    , ci.Name ) ;
Console.WriteLine("* Display Name: {0}"            , ci.DisplayName ) ;
Console.WriteLine("* English Name: {0}"            , ci.EnglishName ) ;
Console.WriteLine("* 2-letter ISO Name: {0}"       , ci.TwoLetterISOLanguageName ) ;
Console.WriteLine("* 3-letter ISO Name: {0}"       , ci.ThreeLetterISOLanguageName ) ;
Console.WriteLine("* 3-letter Win32 API Name: {0}" ,    ci.ThreeLetterWindowsLanguageName   
) ;

return 0 ;
}

the above way i can get current language set of the OS. please discuss this issue in details. thanks

like image 943
Thomas Avatar asked Oct 19 '25 09:10

Thomas


2 Answers

Visual Studio contains a localization feature. You design the form in the default language (for example English) and then, in the form's properties, you can set the "Localizable" property to true and select another language to translate to.

After you've selected the language, you change the captions to the respective language. Then you select another language, change the captions, etc.

Please note: Only add new controls or remove controls in the default language - otherwise the control will not be shown for other translations!

The selection which language will be shown is then made by the .NET framework.

The same applies to resource files as well - to localize a .resx file, create a copy and rename it to match the locale (for example: resources.DE.resx) and add it to the project.

As Daryal said in his comment, further information can be found here.

like image 126
Thorsten Dittmar Avatar answered Oct 21 '25 21:10

Thorsten Dittmar


Localizing with resources is a recommended way to go.

This walkthrough may be helpful for you:

Walkthrough: Localizing Windows Forms

The Visual Studio project system provides considerable support for localizing Windows Forms applications. There are two ways to generate resource files using the Visual Studio development environment:

  • Have the project system generate the resource files for localizable UI elements such as text and images on the form. The resource files are then built into satellite assemblies. These are known as forms-based resources.
  • Add a resource file template and then edit the template with the XML Designer. A reason for doing the latter is to make localizable strings that appear in dialog boxes and error messages. You must then write code to access these resources. These are known as project resources.
  • In general, you should use forms-based resources for all resources specific to a form in your Windows Forms application. You should use project resources for all non-forms-based user interface strings and images, such as error messages.

This walkthrough topic demonstrates both processes in a single Windows Application project.

like image 29
Stas Bushuev Avatar answered Oct 21 '25 23:10

Stas Bushuev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!