Urzpvtch(LanguageSelection)

所属分类:Symbian
开发工具:C/C++
文件大小:43KB
下载次数:6
上传日期:2010-03-03 13:44:39
上 传 者ling8205
说明:  symbian 多语言源码 carbide可运行
(symbian multi lang)

文件列表:
Urzpvtch (0, 2009-08-23)
Urzpvtch\.cproject (6013, 2009-08-23)
Urzpvtch\.project (520, 2009-08-23)
Urzpvtch\application.uidesign (8392, 2009-08-23)
Urzpvtch\data (0, 2009-08-23)
Urzpvtch\data\Urzpvtch.l01 (509, 2009-08-23)
Urzpvtch\data\Urzpvtch.l31 (561, 2009-08-23)
Urzpvtch\data\Urzpvtch.loc (363, 2009-08-23)
Urzpvtch\data\Urzpvtch.rss (1024, 2009-08-23)
Urzpvtch\data\UrzpvtchContainer.l01 (352, 2009-08-23)
Urzpvtch\data\UrzpvtchContainer.l31 (398, 2009-08-23)
Urzpvtch\data\UrzpvtchContainer.loc (390, 2009-08-23)
Urzpvtch\data\UrzpvtchContainer.rssi (423, 2009-08-23)
Urzpvtch\data\Urzpvtch_reg.loc (252, 2009-08-23)
Urzpvtch\data\Urzpvtch_reg.rss (425, 2009-08-23)
Urzpvtch\gfx (0, 2009-08-23)
Urzpvtch\gfx\list_icon.bmp (2356, 2009-08-23)
Urzpvtch\gfx\list_icon_mask.bmp (294, 2009-08-23)
Urzpvtch\gfx\mark_icon.bmp (2134, 2009-08-23)
Urzpvtch\gfx\mark_icon_mask.bmp (166, 2009-08-23)
Urzpvtch\gfx\qgn_menu_Urzpvtch.svg (3771, 2009-08-23)
Urzpvtch\group (0, 2009-08-23)
Urzpvtch\group\bld.inf (125, 2009-08-23)
Urzpvtch\group\Icons_aif_scalable_dc.mk (2250, 2009-08-23)
Urzpvtch\group\Urzpvtch.mmp (1065, 2009-08-23)
Urzpvtch\inc (0, 2009-08-23)
Urzpvtch\inc\Urzpvtch.pan (330, 2009-08-23)
Urzpvtch\inc\UrzpvtchApplication.h (1117, 2009-08-23)
Urzpvtch\inc\UrzpvtchAppUi.h (1726, 2009-08-23)
Urzpvtch\inc\UrzpvtchContainer.h (2859, 2009-08-23)
Urzpvtch\inc\UrzpvtchDocument.h (917, 2009-08-23)
Urzpvtch\sis (0, 2009-08-23)
Urzpvtch\sis\backup_registration.xml (144, 2009-08-23)
Urzpvtch\sis\Urzpvtch.pkg (1593, 2009-08-23)
Urzpvtch\sis\Urzpvtch.sis (9420, 2009-08-23)
Urzpvtch\sis\Urzpvtch.sisx (10512, 2009-08-23)
Urzpvtch\src (0, 2009-08-23)
Urzpvtch\src\UrzpvtchApplication.cpp (4345, 2009-08-23)
Urzpvtch\src\UrzpvtchAppUi.cpp (3030, 2009-08-23)
Urzpvtch\src\UrzpvtchContainer.cpp (6697, 2009-08-23)
... ...

Hi, By default the Symbian/S60 applications will use the current phone language as its language, but many developers want to give the user a chance to change the application's language without changing the phone language. "Language selection by user" http://discussion.forum.nokia.com/forum/showthread.php?t=177512 Here is a solution to let user select the perferred language during application startup. Step 1: At the very beginning of the application startup we show a global list query to offer a list of supported languages for the user, and user makes the choice we remember it in some way. [code] // begin by chen ... #include #include #include void MainL() { _LIT(KPhoneLanugage, "Phone language"); _LIT(KEnglish, "English"); _LIT(KChinese, "Chinese"); CDesCArray* array = new(ELeave) CDesCArrayFlat(5); CleanupStack::PushL(array); array->AppendL(KPhoneLanugage); array->AppendL(KEnglish); array->AppendL(KChinese); // the application framework has not be created yet so we the notifier service to show the list CAknGlobalListQuery* query = CAknGlobalListQuery::NewLC(); TRequestStatus status = KRequestPending; query->ShowListQueryL(array, status); User::WaitForRequest(status); TInt ret = status.Int(); if(ret>=0) { // ret is the index of the user selected item // here we map the user selection to a language code TLanguage language = ELangEnglish; switch(ret) { case 0: { language = User::Language(); break; } case 1: { language = ELangEnglish; break; } case 2: { language = ELangPrcChinese; break; } default: { language = User::Language(); break; } } // here we define a property to hold the user selection, but this is definitely not the only way, for example you can also save it to a file. RProperty::Define(KUidUrzpvtchApplication, 0, RProperty::EInt); RProperty::Set(KUidUrzpvtchApplication, 0, (TInt)language); } CleanupStack::PopAndDestroy(2, array); } GLDEF_C TInt E32Main() { // begin by chen // at this stage we have to create the cleanup stack by ourself // Cleanup stack needed CTrapCleanup* cleanup = CTrapCleanup::New(); if(cleanup) { TRAPD(err, MainL()); if(err != KErrNone) { _LIT(KUserPanic,"Failed to start"); User::Panic(KUserPanic, err); } delete cleanup; } // end by chen return EikStart::RunApplication( NewApplication ); } [/code] Step 2: During application framework initialization we replace the default resource file with the one selected by the user The application's resource file can be changed from the default by overriding ResourceFileName(), see below. [code] #include ... TFileName CUrzpvtchApplication::ResourceFileName() const { TFileName filename = CAknApplication::ResourceFileName(); TInt language = 0; TInt err = RProperty::Get(KUidUrzpvtchApplication, 0, language); if(err==KErrNone) { TFileName fn = filename; _LIT(KExtFormat, "r%d"); TBuf<16> buf; buf.Format(KExtFormat, language); if(buf.Length()<=2) // for example "r1" { _LIT(KZero, "0"); buf.Insert(1, KZero); // now should be "r01" } TInt pos = fn.LocateReverse('.'); fn.SetLength(pos+1); // remove the extention fn.Append(buf); // add new extention // make sure that the filename actually exists, or there will be a User 23 panic TBool exists = ConeUtils::FileExists(fn); if(exists) { filename=fn; } } return filename; } [/code] Note: 1. The title will not be changed because it is defined in _reg.rsc 2. The system strings like CBA "Options" will not be changed Regards Ziteng Chen

近期下载者

相关文件


收藏者