×
Namespaces

Variants
Actions

Multi-language support at run time

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Compatibility
Platform(s):
Symbian
Article
Created: vvsnaresh (21 Mar 2007)
Last edited: hamishwillee (27 Jul 2012)

The following shows you some easy and important steps to provide multi-language support during runtime for S60:

First Step: In your project's MMP file replace the line

LANG SC

with

LANG 01 02 03 04

Here, 01 02 03 and 04 represents the number of languages you want to give support to.


Second Step: You have to create four localization files with file extensions as .l01, .l02, .l03 and .l04 for languages say, Chinese, English Latin and German.In these localization files, one can keep all the strings in the concerned language.

NOTE:It is advisable to follow the TLanguage enumeration found in e32const.h when choosing the number, corresponding to the language.

Third Step: And edit your LOC file as follows:

// 01 is Chinese, 02 is English, 03 is Latin and 04 is German
#ifdef LANGUAGE_01
#include "LangFile.l01"
#endif
 
#ifdef LANGUAGE_02
#include "LangFile.l02"
#endif
 
 
#ifdef LANGUAGE_03
#include "LangFile.l03"
#endif
 
#ifdef LANGUAGE_04
#include "LangFile.l04"
#endif

Fourth Step: <AppName>aif.rss file should look like as follows to localize your application’s caption.

RESOURCE AIF_DATA
{
caption_list=
{
CAPTION { code=01; caption="LangFile"; },
CAPTION { code=02; caption="LangFile"; },
CAPTION { code=03; caption="LangFile"; },
CAPTION { code=04; caption="LangFile"; }
};
 
app_uid=0x02a5dd83;
num_icons=2;
embeddability=KAppNotEmbeddable;
newfile=KAppDoesNotSupportNewFile;
}


Fifth Step: Now, change the class derived from CAknApplication; Over-ride ResourceFileName() function from CEikApplication to your CYourApplicationApp class.

TFileName CLangFileApp::ResourceFileName() const
{
return TFileName();
}

Sixth Step: Now, some changes are required in your AppUi class; You have to pass ENonStandardResourceFile for the function call of BaseConstructL() in your AppUi class’s ConstructL() function.

void CLangFileAppUi::ConstructL()
{
BaseConstructL( ENonStandardResourceFile );
//...
}

Add the following new function in your AppUi class;

void CLangFileAppUi::ChooseLanguageL(TInt aLanguageIndex)
{
_LIT(KResourceFileName, "LangFile.r%02d");
TFileName resFileName;
 
resFileName.Format(KResourceFileName, aLanguageIndex);
 
#if !defined(__WINS__) && !defined(__WINSCW__)
// Device
CompleteWithAppPath(resFileName);
#else
// Emulator
resFileName.Insert(0, KEmulatorPath);
#endif
 
if (iOffset) iCoeEnv->DeleteResourceFile(iOffset);
iOffset = iCoeEnv->AddResourceFileL(resFileName);
}

Now you can change the language of the application by calling ChooseLanguageL([LanguageIndex]) function.

Seventh Step: Add the following in your .pkg file;

"\Symbian\7.0s\Series60_v21\Epoc32\data\z\system\apps\LangFile\LangFile.r01"
-"!:\system\apps\LangFile\LangFile.r01"
"\Symbian\7.0s\Series60_v21\Epoc32\data\z\system\apps\LangFile\LangFile.r02"
-"!:\system\apps\LangFile\LangFile.r02"
"\Symbian\7.0s\Series60_v21\Epoc32\data\z\system\apps\LangFile\LangFile.r03"
-"!:\system\apps\LangFile\LangFile.r03"
"\Symbian\7.0s\Series60_v21\Epoc32\data\z\system\apps\LangFile\LangFile_caption.r01"
-"!:\system\apps\LangFile\LangFile_caption.r01"
"\Symbian\7.0s\Series60_v21\Epoc32\data\z\system\apps\LangFile\LangFile_caption.r02"
-"!:\system\apps\LangFile\LangFile_caption.r02"
"\Symbian\7.0s\Series60_v21\Epoc32\data\z\system\apps\LangFile\LangFile_caption.r03"
-"!:\system\apps\LangFile\LangFile_caption.r03"

Related links:


This page was last modified on 27 July 2012, at 10:32.
49 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.

×