|
Symbian
IntroductionDynamic language support for Symbian is using Get Localization API's. It provides trivial UI, downloader and string management for Symbian. Current status: in production use but lacks functionality for full avkon support. DetailsSymbian is problematic in many ways, most of the strings are defined in resource files so it's hard to change them dynamically. We've implemented environment that makes it easy to localize Symbian application dynamically. Give it a try and send us feedback. It implements also simple dialog based UI for selecting the language. Using DLS for SymbianFunctionality is implemented as one singleton class called CLocEnv so it is really easy to use. 1. In your AppUI constructor, call: void CCalSyncAppUi::ConstructL()
{
BaseConstructL(EAknEnableSkin);
TRAP_IGNORE(CLocEnv::Static()->InitLanguageL());
...
}This initializes the language which is downloaded to applications default directory. In case there's no language, it will leave (in this case does nothing which is normally what we want so users can use app with original language). 2. Downloading and installing languages CGLClientUI* ui = CGLClientUI::NewL(); ui->Client()->SetAccessPoint(iIapId); // this is not necessary. ui->ChangeLanguageL(); That's it, dialog based UI will be shown to user and the file will be downloaded, it will also suggest user to restart your application in order language to take effect. This is needed in order to really load resources etc. again but if your app is simple, calling InitLanguage after this should be enough. 3. Translate your strings In case you've hard-coded all your strings it's extremely easy to take CLocEnv in use: Your current code (in case you've forgotten that L is deprecated) dialog->SetTitleL(_L("Warning"));And to get that string localized you do: dialog->SetTitleL(_LL("Warning"));LL is called Localized Literal. Otherwise you can use LS macro for normal descriptors. For example: _LIT(KText, "test");
RDebug::Print(_L("%S"), &LS(KText));
// will print out "test" in selected language. E.g.
// if Finnish is selected, text printed out is "testi"When using String Loader: HBufC* recv = StringLoader::LoadLC(R_QTN_INFO_RECEIVED, iEikonEnv); TBuf<128> recvText; StringLoader::Format(recvText,LS(recv->Des()),-1,aBytesReceived / 1024); Note the usage of LS macro in Format function. It translates loaded text before it is formatted. Special casesSettings listDue the design of avkon settings list it's not possible to dynamically change setting items. So unfortunately we need to do small hack here. This is probably something you've already in your settings list container ConstructL(). Could be something different too but basically it's constructing your settings list from resource. TResourceReader reader; iCoeEnv->CreateResourceReaderLC( reader, R_SETTING_LIST ); iItemList->ConstructFromResourceL(reader); You need to switch it to this: CLocEnv::Static()->ConstructSettingItemListL(iItemList, R_SETTING_LIST); This is due to the fact that it's not possible to translate setting items on the fly so we need to do it when we load the resource. CAknEnumeratedTextPopupSettingItemThese things are difficult to translate so this helper function will do it for you. CLocEnv::Static()->TranslateEnumeratedTextPopupSettingItem(static_cast<CAknEnumeratedTextPopupSettingItem*> (item); DownloadLatest source code is available under our GLToolkit repository: http://code.google.com/p/gltoolkit/source/browse/#hg/gl/symbian |