×
Namespaces

Variants
Actions

本地化应用程序字符串

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

文章
huwell 在 08 Oct 2008 创建
最后由 hamishwillee 在 15 Dec 2011 编辑

CS000807


  • 开发伙伴平台:

S60 3rd Edition

S60 3rd Edition, FP1

S60 3rd Edition, FP2


  • 详细描述

这个实例代码描述了如何本地化一个应用程序的文本字符串,改示例可以自签名执行。


  • 步骤

1、生成data\[app].rls文件

2、将本地化信息写入其中

#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"
 
#endif


3、增加不同本地化字符串内容到相关文件(如data\[app]_loc.l01和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."
<code>
 
4、在data\[app].rss中生成资源信息
<code>
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、使用StringLoader加载并格式化资源字符

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


6、插入LANG标识至group\[app].mmp文件中

LANG            SC 01 09
This page was last modified on 15 December 2011, at 09:16.
31 page views in the last 30 days.
×