# Supporting multiple languages

The S60 platform supports multiple languages, and mobile device users can select the language used by their devices for UI texts. The Web Runtime (WRT) environment provides localization support, so if you plan to provide your widget to mobile device users in multiple countries around the world, you should consider supporting several languages in your widget.

In addition to UI text strings that are language dependent, a widget may contain data types that require localization according to the target country or region. Examples of such data types include date and time formatting, time zone and currency. Also images may need to be localized.

Note: To enable localization of your widget, do not hard code text strings in your widget HTML or JavaScript files.

The WRT environment uses different language versions of a widget through resource loading. You need to implement localization information for your widget in resource-specific files that you store under language project directories. When a resource that is defined relatively to the widget root directory is to be loaded, the system first looks for the resource within the language project directory that matches with the current device language. If the localized resource is found, it is loaded and used. Otherwise the default resource under the root directory of the widget is loaded. The resources for the default language are always stored directly under the root directory.

For an example of localizing a widget, see Localizing STEW.

### To support multiple languages

1. Create a language project directory at the root level of your widget for each language that you plan to support, for example `en.lproj` and `fi.lproj` for English and Finnish.

   Note: You do not need to create a language project directory for the default language, as the files for the default language are stored directly at the root of the widget.

2. Localize the display name of the widget using `infoplist.strings` files.

3. Localize the display texts of the widget using separate JavaScript files for text strings.

4. Localize any resources, such as images, if they are language or region dependent.

### Selecting the widget language

The WRT environment loads localized resources from language project directories only when the location of the resources is defined relatively to the root directory of the widget. Localized resources are used in the following contexts:

- The `@import` directive is used in the main HTML document. For example:

      @import "localizedStyle.css"

- A resource is loaded dynamically using JavaScript code. For example:

      document.getElementById('image').setAttribute('src', 'image.jpg');

- The `src` attribute of an HTML tag is used. For example:

      <script src='localizedScript.js' />
      <img src="localizedImage.gif" />

Checking the current language setting of the device and using that language for the widget is done automatically when the widget is launched. If the user changes the language setting of the device while the widget is running, this will cause the widget to exit and the mobile device to reboot.

Note: Changing the language of the widget may also affect the layout of the UI. For example, supporting a right-to-left language in your widget may require that you mirror some UI components around the Y axis. To localize the widget layout, use CSS files for each layout type and specify the file in the main HTML file. For more information, see section Localizing widget layout.