Creating a Multi-Lingual Application

Iron Speed Designer can generate applications with multiple language translation files (RESX) included in your application via the Application Wizard.  If you selected this option, you must still provide a means for your application users to select which language (culture) they wish to use at run-time.

Iron Speed Designer provides a variety of mechanisms for setting the application culture.  Before describing them, it is useful to understand how your application culture is set in your generated application.

Programmatically Setting the Application Culture

The application’s BasePage class sets application culture based on session variables and URL parameters.  Either can be used depending on your programming requirements and style.

Function

Session Parameter

URL Parameter

Set the UI culture of the application

AppCultureUI

culutreui

Set the application formatting

AppCulture

culture

The values assigned to these parameters must be valid culture names, such as “en-US”, “en-UK”.  A list of culture names is available at this Microsoft website:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csvr2002/htm/cs_rp_catalogmanager_list_c.asp

The BasePage class sets the application culture for the application thread by setting these variables:

System.Threading.Thread.CurrentThread.CurrentUICulture

System.Threading.Thread.CurrentThread.CurrentCulture

The GetValueFromResourceFile method in the MiscUtils class of the BaseClasses reads the specific language resource file (RESX) based on value of System.Threading.Thread.CurrentThread.CurrentUICulture.

The SetPageCulture method in the BasePage class sets the cultures of the thread and is called in the Page_Init method of the BasePage class.  This method can be overridden to implement a custom method of setting user culture.

Once the culture is set, it is applicable for the duration of the session.  Note that the culture is set per application thread, so if a user has two separate browser windows, they could potentially have different cultures set.

If the user chooses a culture for which there is no language translation, then the default (English) translation is added and you must provide the language translation yourself.  The default culture is always added to the application, and even if you remove it from the Select Language dialog, it will be added to the application.

Both SetLanguagePage.aspx and the code customization read the names of available cultures from the “App_GlobalResources” folder.

How to Set the Application Culture

A variety options for setting the application culture are available to you:

The SetLanguagePage.aspx Page

Using URL Parameters to set Application Culture

Using a Code Customization to set Application Culture

Read Browser Language Settings to set Application Culture

Read User Language Preference from Database

Custom Coding Approaches for Setting Application Culture

See Also

Localizing (Internationalizing) Your Application