Revision as of 13:07, 17 July 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Localizing strings on Symbian C++ apps

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.

Article Metadata
Tested with
Devices(s): Nokia E90 Communicator
Platform(s): S60 3rd Edition
S60 3rd Edition, FP1
S60 3rd Edition, FP2
S60 3rd Edition FP2
S60 3rd Edition FP1
S60 3rd Edition (initial release)
Keywords: StringLoader
Created: tapiolaitinen (04 Feb 2008)
Last edited: hamishwillee (17 Jul 2012)


This code example describes how to localize the text strings of an application.

This snippet can be self-signed.


1. Create the data\[app].rls file.

2. Write the localization information into it:

#ifdef LANGUAGE_SC          // Default: UK English
#include "app_loc.l01"
#elif defined LANGUAGE_01 // UK English
#include "app_loc.l01"
#elif defined LANGUAGE_09 // Finnish
#include "app_loc.l09"

3. Add the localization strings into the appropriate files (for example, data\[app]_loc.l01 and data\[app]_loc.l09):

// Strings in data\[app]_loc.l01:
rls_string STRING_r_localized_text "Localized text."
rls_string STRING_r_localized_string_param "Localized string parameter: %U."
rls_string STRING_r_localized_number_param "Localized number parameter: %N."
// Strings in data\[app]_loc.l09:
rls_string STRING_r_localized_text "Kotoistettu teksti."
rls_string STRING_r_localized_string_param "Kotoistettu merkkijonoparametri: %U."
rls_string STRING_r_localized_number_param "Kotoistettu numeroparametri: %N."

4. Create resources from localized strings in data\[app].rss:

RESOURCE TBUF r_localized_text { buf=STRING_r_localized_text; }
RESOURCE TBUF r_localized_string_param { buf=STRING_r_localized_string_param; }
RESOURCE TBUF r_localized_number_param { buf=STRING_r_localized_number_param; }

5. Use StringLoader to load and format resource strings:

#include <stringloader.h>
HBufC* resLocalizedText = StringLoader::LoadLC(R_LOCALIZED_TEXT);
// Use resLocalizedText
_LIT(KString, "A string");
HBufC* resLocalizedStringParam = StringLoader::LoadLC(R_LOCALIZED_STRING_PARAM, KString);
// Use resLocalizedStringParam
TInt number = 34;
HBufC* resLocalizedNumberParam = StringLoader::LoadLC(R_LOCALIZED_NUMBER_PARAM, number);
// Use resLocalizedNumberParam

6. Insert the LANG attribute into the group\[app].mmp file:

LANG SC 01 09
This page was last modified on 17 July 2012, at 13:07.
62 page views in the last 30 days.