×
Namespaces

Variants
Actions

Localising strings in Symbian Web Runtime

From Nokia Developer Wiki
Jump to: navigation, search

This code snippet demonstrates how to localise strings in Symbian Web Runtime.

Article Metadata
Code ExampleTested with
Devices(s): Nokia 5800 XpressMusic, Nokia 6220 Classic
Compatibility
Platform(s): S60 5th Edition, S60 3rd Edition FP2
S60 5th Edition
S60 3rd Edition FP2
Article
Keywords: localization
Created: MiGryz (26 Feb 2009)
Last edited: hamishwillee (04 Oct 2012)

Contents

Overview

To localise the strings, you should place the files for the default language into the root directory of your widget and the localised files into subfolders named "***.lproj", without quotes, where *** is the language code. For example:

/strings.js  (the JavaScript file containing strings for the default language)
    /en.lproj/strings.js  (the JavaScript file containing English strings)
    /ru.lproj/strings.js  (the JavaScript file containing Russian strings)
    /de.lproj/strings.js  (the JavaScript file containing German strings)

For the list of language codes, see Web Runtime localisation support.

Source file: wrtstub.html

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="StyleSheet" href="style/general.css" type="text/css" />
<script type="text/javascript" src="script/common.js" />
<script type="text/javascript" src="strings.js"/>
<script type="text/javascript" src="script/wrtstub.js" />
<title>WRT Stub</title>
</head>
<body>
<div id="bodyContent" class="bodyContent">
<hr />
<div id="txt"></div>
<hr />
</div>
</body>
</html>

Source file: infoplist.strings

DisplayName = "DEF_Localization"

Source file: en.lproj/infoplist.strings

DisplayName = "EN_Localization"

Source file: de.lproj/infoplist.strings

DisplayName = "DE_Lokalisierung"

Source file: ru.lproj/infoplist.strings

DisplayName = "RU_Локализация"

Source file: localizationStrings.js

// Executes the snippet.
function executeSnippet() {
showLocalizedString();
}
 
/**
* Shows a localized string.
*/

function showLocalizedString() {
document.getElementById('txt').innerHTML = '<p>' + mainString + '</p>';
}

Source file: strings.js

var mainString = 'DEF_Localization';

Source file: en.lproj/strings.js

var mainString = 'English string';

Source file: de.lproj/strings.js

var mainString = 'Deutsch zeile';

Source file: ru.lproj/strings.js

var mainString = 'Русская строка';

Postconditions

Upon installation, the application sets its name according to the currently used language.

When the user selectes the Execute snippet menu item, the application shows a string between two horizontal lines in the currently used language. For example, on a device with English language, the user will see a string in English.

There are strings for English, German, and Russian languages, and one default string.

Supplementary material

This code snippet is part of the stub concept, which means that it has been patched on top of a template application in order to be more useful to developers. The version of the WRT stub application used as a template in this snippet is v1.1.

This page was last modified on 4 October 2012, at 08:59.
65 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×