Beruflich Dokumente
Kultur Dokumente
1 Introduction
In the previous article we outlined the measures required to localize your applications for versions of
Symbian OS prior to version 9. In this article we will complete the picture by looking at the changes
required for Symbian OS v9 and later.
The release of Symbian OS v9 marked a major watershed, with the introduction of an enhanced security
architecture. The constraints imposed by the new security model have necessitated some minor changes
in the structure of applications, and these necessarily result in some changes to the structure and location
of resource files involved in localization. For a detailed overview of platform security and migrating
applications to v9, the reader is referred to “Symbian OS Platform Security” by Craig Heath (Wiley 2006).
In this paper we will focus only on the changes relevant to the localization process. Fortunately these are
minor and the underlying principles outlined in the previous paper remain.
TARGET HelloWorld.exe
TARGETTYPE exe
UID 0x100039CE 0xE0000003
SOURCEPATH .
SOURCE HelloWorld_Main.cpp
SOURCE HelloWorld_Application.cpp
SOURCE HelloWorld_Document.cpp
SOURCE HelloWorld_AppUi.cpp
SOURCE HelloWorld_AppView.cpp
USERINCLUDE .
SYSTEMINCLUDE \epoc32\include
For each .RSS file a RESOURCE block is specified, commencing with START and terminating with
END. The optional HEADER keyword causes a resource header (.RSG) file to be created in the system
include folder …\epoc32\include. The TARGETPATH statement specifies the location of the compiled
resource file (.RSC). In Symbian OS v9 and later, data caging (part of the platform security architecture)
requires resources to be placed into the correct path, either \resource for resources that are public but
read-only, or \private\<secure_ID>, for resources that are private to the application with <secure_ID>
(where <secure_ID> is the application’s UID3, if not otherwise specified). The LANG keyword has the
same meaning as before. So in the example above the resource compiler will be invoked twice, for each
of the specified locales.
#include <eikon.rh>
#include <eikcore.rsg>
#include <appinfo.rh>
#include <avkon.rh>
#include <avkon.rsg>
#include "helloworld.hrh"
#ifdef LANGUAGE_01
#include "helloworld.l01"
#elif defined LANGUAGE_02
#include "helloworld.l02"
#endif
RESOURCE RSS_SIGNATURE { }
RESOURCE EIK_APP_INFO
{
hotkeys=r_example_hotkeys;
menubar=r_example_menubar;
cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
}
2
MENU_ITEM { command=EExampleItem1; txt=STRING_r_example_item1; },
MENU_ITEM { command=EExampleItem2; txt=STRING_r_example_item2; },
MENU_ITEM { command=EAknSoftkeyExit; txt=STRING_r_example_close; }
};
}
RESOURCE TBUF r_example_text_Hello { buf=STRING_r_example_text_hello; }
RESOURCE TBUF r_example_text_Item0 { buf=STRING_r_example_item0; }
RESOURCE TBUF r_example_text_Item1 { buf=STRING_r_example_item1; }
RESOURCE TBUF r_example_text_Item2 { buf=STRING_r_example_item2; }
This is identical in structure to the pre v9 version, using the same conditional include of the .RLS files we
saw in Part 1:
#ifdef LANGUAGE_01
#include "01-strings.rls"
#else if defined LANGUAGE_02
#include "02-strings.rls"
#endif
The example below is the contents of helloworld.l02, which contains the resources for locale 02
(France).
// Strings localised for France
rls_string STRING_r_example_first_menu "Bonjour"
rls_string STRING_r_example_item0 "Élément 0"
rls_string STRING_r_example_item1 "Élément 1"
rls_string STRING_r_example_item2 "Élément 2"
rls_string STRING_r_example_close "Fin"
rls_string STRING_r_example_text_hello "Bonjour Monde!"
The Application Registration file by convention has the same filename as the application, but with a
_reg suffix and replaces the Application Information File (AIF) file supported on earlier versions. The
registration file must build into a private data caged directory belonging to the Application Architecture
Server, since the application architecture is ultimately responsible for launching all applications. Putting
the _reg file in a private directory prevents a malicious application replacing an existing application’s
_reg file with a spoof version. The application registration file is shown below.
3
#include <appinfo.rh>
UID2 KUidAppRegistrationResourceFile
UID3 0xE0000003 // application UID
RESOURCE APP_REGISTRATION_INFO
{
app_file = "HelloWorld";
localisable_resource_file = "\\resource\\apps\\HelloWorld_loc";
}
The APP_REGISTRATION_INFO structure minimally needs to provide the name (but not extension) of
the application binary (using the app_file statement). If a localisable icon/caption definition file is
provided, as in this example, its full path and filename must be specified, excluding the drive letter and
file extension. This file defines the application's captions and the name of the icon file. By convention it
has the same filename as the application, but with a _loc suffix.
#include <AppInfo.rh>
#ifdef LANGUAGE_01
#include "helloworld.l01"
#elif defined LANGUAGE_02
#include "helloworld.l02"
#endif
RESOURCE LOCALISABLE_APP_INFO
{
short_caption = STRING_r_example_short_caption;
caption_and_icon =
{
CAPTION_AND_ICON_INFO
{
caption = STRING_r_example_caption;
number_of_icons = 1;
icon_file = "\\resource\\apps\\helloworld.mbm";
}
};
}
The HelloWorld_loc.rss file is a standard localisable Symbian resource file, so it is compiled by the
resource compiler by including lines similar to the following in the application's .MMP file:
START RESOURCE HelloWorld_loc.rss
TARGETPATH \resource\apps
LANG 01 02
END
#{"HelloWorld_v9_s60_EN","HelloWorld_v9_s60_FR"},(0xE0000003),1,0,1, TYPE=SA, NC
"E:\Symbian\S60_3rd\EPOC32\RELEASE\ARMV5\UREL\HelloWorld_S60.exe" -"!:\sys\bin\HelloWorld_S60.exe"
"E:\Symbian\S60_3rd\EPOC32\data\Z\private\10003a3f\apps\HelloWorld_reg.RSC"
- "!:\private\10003a3f\import\apps\HelloWorld_reg.RSC"
{"E:\Symbian\S60_3rd\EPOC32\data\Z\resource\apps\HelloWorld.R01"
"E:\Symbian\S60_3rd\EPOC32\data\Z\resource\apps\HelloWorld.R02"
} -"!:\resource\apps\HelloWorld.RSC"
{"E:\Symbian\S60_3rd\EPOC32\data\Z\resource\apps\HelloWorld_loc.R01"
"E:\Symbian\S60_3rd\EPOC32\data\Z\resource\apps\HelloWorld_loc.R02"
} -"!:\resource\apps\HelloWorld_loc.RSC"
4
Note that where a single string or file name varies due to localization, the number of options within the
braces must match the number of locale variants specified in the .MMP file (in this case, we have just the
two).
6 Summary
In this second part of “How to localize your Symbian OS application” we have considered the changes
necessary to migrate your application to Symbian OS version 9 and later. The underlying principles
remain the same as for earlier versions, but the requirements of Platform Security necessitate some
syntactical changes to the MMP and associated resource files.
NOTE: As of the current issue of this document, there is a defect in CodeWarrior and Carbide.c++ that
prevents the code examples given in this paper from being correctly built. A workaround is available for
this defect and the updated file in question (ide_cw.pm) is included in recent builds of Symbian OS v9.2
and v9.3. The updated file is also supplied as an additional download with this paper and should
replace the existing file in \epoc32\tools.