org.symbian.tools.wrttools.doc.WebDeveloper/html/GUID-C442113C-5FBE-493E-AD5A-CF0A0FB3C5FD.html
author Eugene Ostroukhov <eugeneo@symbian.org>
Mon, 15 Mar 2010 17:56:08 -0700
changeset 268 ef733cd772bb
parent 229 716254ccbcc0
permissions -rw-r--r--
Bug 2213 - User is not prompted to save when debug session is started
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
229
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
     1
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
     2
<!DOCTYPE html
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
     3
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
     4
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="copyright" content="(C) Copyright 2009"/><meta name="DC.rights.owner" content="(C) Copyright 2009"/><meta name="DC.Type" content="concept"/><meta name="DC.Title" content="Localizing widget display text"/><meta name="abstract" content="Widget display text can be localized at run time to match with the current system language."/><meta name="description" content="Widget display text can be localized at run time to match with the current system language."/><meta name="DC.Relation" scheme="URI" content="GUID-63F29096-C1A3-45DB-9E2F-6110562E0237"/><meta name="DC.Relation" scheme="URI" content="GUID-4CD10DEB-6C79-4320-AC82-F17DD264CF28"/><meta name="DC.Relation" scheme="URI" content="GUID-1EFD7043-E9B8-4B4E-9EA6-A20B3EECC14A"/><meta name="DC.Relation" scheme="URI" content="GUID-E3EA4F85-E0AE-42AB-8E51-EFD3F0E0A51E"/><meta name="DC.Format" content="XHTML"/><meta name="DC.Identifier" content="GUID-C442113C-5FBE-493E-AD5A-CF0A0FB3C5FD"/><title>Localizing widget display text </title><script type="text/javascript">
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
     5
      function initPage() {}
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
     6
    </script><link href="../PRODUCT_PLUGIN/book.css" rel="stylesheet" type="text/css"/><link href="css/s60/style.css" rel="stylesheet" type="text/css" media="all"/></head><body onload="initPage();"><div class="body"><div class="contentLeft prTxt"><h1 class="pageHeading" id="GUID-C442113C-5FBE-493E-AD5A-CF0A0FB3C5FD">Localizing widget display text</h1><div><p>Widget display text can be localized at run time to match with the current system language.</p>
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
     7
<div><h3>To localize widget display text</h3><ol>
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
     8
<li id="GUID-B23E2FC2-0CA8-4E4E-ABFC-2842D96C5504"><a name="GUID-B23E2FC2-0CA8-4E4E-ABFC-2842D96C5504"><!----></a><p>Predefine the display text strings in separate JavaScript files that you create for each supported language.</p><p>The name of the JavaScript file is arbitrary, but the name must be identical for all the supported languages so that you need to specify the name only once in the <a href="GUID-C294F32D-CAC7-499C-AD4B-701B9AB57ACA.html#GUID-C294F32D-CAC7-499C-AD4B-701B9AB57ACA">main HTML document</a>.</p></li>
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
     9
<li id="GUID-7082F7A3-1E8F-4A7D-816F-F42FBB46CA4D"><a name="GUID-7082F7A3-1E8F-4A7D-816F-F42FBB46CA4D"><!----></a><p>In the JavaScript files, use arrays for holding the localized text strings.</p><p>The name and structure of the array are arbitrarily implemented but they must be identical for all languages (except for the localized text strings). For an example of creating the array, see <a href="GUID-8DC78944-809B-462B-BEC2-0114696F8B14.html#GUID-8DC78944-809B-462B-BEC2-0114696F8B14">Localizing STEW</a>.</p></li>
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    10
<li id="GUID-2F2F7E2D-1DEE-45C2-8B1E-67AFAC461F49"><a name="GUID-2F2F7E2D-1DEE-45C2-8B1E-67AFAC461F49"><!----></a><p>Store the JavaScript files into the appropriate <a href="GUID-71BE0F0B-B6B2-475C-A87B-A04E207F3292.html#GUID-71BE0F0B-B6B2-475C-A87B-A04E207F3292">language project directories</a>.</p></li>
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    11
<li id="GUID-47A66210-F438-4446-9A0E-E296917F3D82"><a name="GUID-47A66210-F438-4446-9A0E-E296917F3D82"><!----></a><p>Provide a JavaScript file for default text strings (for example, in English) and store it in the root directory of the widget.</p><p>The default text strings are used in case the current system language does not match with any provided local language. The name of the default text strings file must be identical to the name of the localized text strings files.</p></li>
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    12
</ol></div>
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    13
<div><h3>Example</h3><p>The following pieces of code provide an example of localizing display text to English and Finnish:</p><p><em>Specified in the main HTML document:</em></p><pre class="codeblock" id="GUID-04BBDE79-9FEC-4B70-8A85-1CA1E3BC5A71">&lt;script type="text/javascript" src="localizedTextStrings.js" /&gt;</pre><p><em>Implemented in a </em><code>localizedTextStrings.js</code><em> JavaScript file:</em></p><p>English version for the English language directory <code>en.lproj</code>:</p><pre class="codeblock" id="GUID-76CCBB66-06E1-43AA-B3BB-2D92D94FAAE0">  var localizedMenu = new Array();
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    14
  localizedMenu['setting'] = "Settings";
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    15
  localizedMenu['open'] = "Open";
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    16
  localizedMenu['close'] = "Close";
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    17
   
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    18
  var localizedInfo = new Array();
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    19
  localizedInfo['congrat'] = "Congratulations!";
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    20
</pre><p>Finnish version for the Finnish language directory <code>fi.lproj</code>:</p><pre class="codeblock" id="GUID-30C8A6A9-C463-4140-9291-E785F9FED4CF">  var localizedMenu = new Array();
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    21
  localizedMenu['setting'] = "Asetukset";
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    22
  localizedMenu['open'] = "Avaa";
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    23
  localizedMenu['close'] = "Sulje";
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    24
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    25
  var localizedInfo = new Array();
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    26
  localizedInfo[0] = "Onneksi olkoon!";
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    27
</pre><p>Default version in English to be stored in the widget root directory:</p><pre class="codeblock" id="GUID-3FA7B29E-9354-464C-A839-1C7B5B0260E5">  var localizedMenu = new Array();
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    28
  localizedMenu['setting'] = "Settings";
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    29
  localizedMenu['open'] = "Open";
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    30
  localizedMenu['close'] = "Close";
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    31
   
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    32
  var localizedInfo = new Array();
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    33
  localizedInfo['congrat'] = "Congratulations!";
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    34
</pre><p><em>Defined in the JavaScript file that implements the logic of the widget:</em></p><pre class="codeblock" id="GUID-EE1CD136-D67D-4B06-9362-0BBA742B49BF">function init() {
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    35
  var settingMenuItem = new MenuItem(loadLocalizedMenu("setting"), 10);
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    36
  var openMenuItem = new MenuItem(loadLocalizedMenu("open"), 11);
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    37
  var playMenuItem = new MenuItem(loadLocalizedMenu("close"), 12);
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    38
  ...
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    39
	 displayInfo(0);
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    40
}
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    41
function displayInfo(index) {
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    42
  alert(localizedInfo[index]);
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    43
}
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    44
function loadLocalizedMenu(index) {
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    45
  if (localizedMenu[index])
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    46
    return localizedMenu[index];
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    47
  else 
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    48
    return "not found";
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    49
}
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    50
</pre></div>
716254ccbcc0 Fixed 2046: WRTKit help topics. Fixed 2170: Added support for Web Developer Library. Fixed 1952: Event Trigger icons unreadable
tasneems@symbian.org
parents:
diff changeset
    51
</div></div></div><div class="footer"><hr/><div class="copy">© Nokia 2009.</div></div></body></html>