Visual Basic 2010 : Localizing Applications - Windows Forms Localization

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
Limiting applications’ user interfaces to just one language means limiting your business. If you want to increase the possibilities of your applications being sold worldwide, you need to consider creating user interfaces that support multiple languages and culture specifications of your users. Of course, you can give users the option to select the desired language or provide localized interfaces for a particular country, but the main concept is that localization is a common requirement in modern applications. The .NET Framework helps developers in localizing applications with several kinds of resources.

Introducing .NET Localization

The .NET Framework provides the infrastructure for application localization via the System.Globalization namespace. The most important class in this namespace is the CultureInfo class that allows getting or setting information on the current application culture or on new custom settings. Generally this class works with the System.Threading.Thread.CurrentThread class that provides access to the thread representing your executable and that exposes the CurrentCulture and CurrentUICulture properties that you can assign with a CultureInfo object. The following code demonstrates how to get information on the current thread culture and how to set a new CultureInfo:

'Requires an Imports System.Globalization directive

'Gets the current culture and shows information
Dim culture As CultureInfo = System.Threading.Thread.

'Creates an instance of the CUltureInfo class
'based on the Italian culture and sets it as
'the current culture
Dim customCulture As New CultureInfo("it-IT")
        CurrentCulture = customCulture

The CultureInfo class provides lots of properties that enable applications to adhere to the required culture specifications. For example, DisplayName shows the name of the culture as it appears on the system, DateTimeFormat specifies the appropriate format for date and time in the specified culture, and NumberFormat provides specifications on how numbers and percentage need to be formatted in the specified culture.

Windows Forms Localization

If you are an experienced Windows Forms developer, maybe you already faced the localization problem with this technology. There are different ways for localizing a Windows Forms application, but basically all of them rely on managed resources. The easiest way for localizing a Windows Forms application is to take advantage of the Visual Studio Designer so that the IDE generates the appropriate resources files for you. An example is of course the best way for providing explanations; the goal of this an example is to localize a Windows Forms application in both English and Italian. Run Visual Studio 2010, create a new Windows Forms project with Visual Basic 2010, and name it WindowsFormsLocalization. Follow these steps:

Drag a Button from the toolbox onto the new form surface, and set its Text property as Localized button.

Drag a Label from the toolbox onto the new form surface, and set its Text property as Localized label.

Select the form, and in the Properties window set its Localizable property as True; then set its Language property as Italian.

Select the Button and set its Text property as Pulsante localizzato (in Italian).

Select the Label and set its Text property as Etichetta localizzata.

Build the project and enable the Show All Files view in Solution Explorer.

You notice that Visual Studio has generated a new it-IT subfolder under Bin\Debug (or Bin\Release) containing a satellite assembly where localized resources are stored. Moreover, Visual Studio generated a new localized resources file for the current form named storing the localized information for design time. If you try to run the application, you notice that it is still localized in English. This is because you need to explicitly assign in code the new localized culture. This can be accomplished by adding the following code (which requires an Imports System.Globalization directive) at the beginning of the application startup, which is typically the constructor, before the InitializeMethod is invoked:

Public Sub New()

    With Threading.Thread.CurrentThread
        .CurrentUICulture = New CultureInfo("it-IT")
        .CurrentCulture = New CultureInfo("it-IT")
    End With
    ' This call is required by the designer.

    ' Add any initialization after the InitializeComponent() call.

End Sub

The code simply assigns to the current thread the new culture information that will be retrieved from the related subfolder and satellite assembly. Figure 1 shows how the application looks with localized controls.

Figure 1. The localized Windows Forms application in action.

Windows Forms localization is straightforward because you can take advantage of the Visual Studio Designer. Unfortunately this is not the same in WPF applications, where a number of manual steps are required, as explained in the next section.

Top 10
Free Mobile And Desktop Apps For Accessing Restricted Websites
TOYOTA CAMRY 2; 2.5 : Camry now more comely
KIA SORENTO 2.2CRDi : Fuel-sipping slugger
How To Setup, Password Protect & Encrypt Wireless Internet Connection
Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
Backup & Restore Game Progress From Any Game With SaveGameProgress
Generate A Facebook Timeline Cover Using A Free App
New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
- Messages forwarded by Outlook rule go nowhere
- Create and Deploy Windows 7 Image
- How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
- Creating and using an unencrypted cookie in ASP.NET
- Directories
- Poor Performance on Sharepoint 2010 Server
- SBS 2008 ~ The e-mail alias already exists...
- Public to Private IP - DNS Changes
- Send Email from Winform application
- How to create a .mdb file from ms sql server database.......
programming4us programming4us