| Reply | « Previous Thread | Next Thread » |
|
上下文相关帮助(Context Sensitive Help)可以根据用户选择显示相应的帮助,用于解决在操作过程中所遇到的疑难问题。在实际当中,某个应用的使用者可能来自不同的国家和地区,使用着不同的语言文字,有着不同的习惯。如果我们希望自己开发的应用获得最大的用户群,则必须在用户界面(UI)的设计上考虑到这一可能的事实。为不同国家和地区的潜在用户设计适合其使用的界面便成了开发者们必然的选择,这在Symbian /C++开发中被称之为“本地化”(Localization)。
本地化应用不同于平时所用的电脑中的那些不同语言版本的同一软件,(例如英文版、简体中文版、繁体中文版)。也并非真的为每个语种设计单独的用户界面或单独应用,而是针对同一用户界面在不同语种环境中的不同要求而做一些变化。其基本原理就是,根据设备的语言设置调用其相应的经过编译的资源文件,以合成适合该语种的用户界面,使得应用象专门为使用该语言的人群而设计的一样。最典型的应用是对用户界面组件中显示字串的本地化,也就是%EPOCROOT%\Examples\toolsandutilities\localize\和%EPOCROOT%\Series60Ex\language\这两个例程中所做的那样。 不过在应用中不仅是字串有本地化的要求,同样被要求的还有帮助、图标、图片,甚至是动画、音频、视频。当然,动画、音频、视频的本地化在现今的硬件条件下我个人不主张,因为那样做会使应用占据过多的存储空间,这对在资源受限设备上的开发来说是不利的。图标、图片倒还可以接受,但即便是本地化图标和图片,它们也应该尽量小和少。 可是帮助不同于以上所说的资源,它基本上只是些文本,只要语言精练就占不了多大空间,所以帮助本地化和字串本地化是很类似的,特别是当用简单的弹出对话框显示帮助则几乎完全是一回事,也就是字串长度长一些。但如果涉及到上下文相关帮助的本地化,其和单纯的字串本地化相比,虽然基本原理相同,但所采用的具体方法就有所区别了。 用过上下文相关帮助的开发者都知道,首先应该为应用建立帮助源文件(.rtf),以及帮助项目文件(.cshlp)和可选的样式自定义文件(custom.xml),通过cshlpcmp编译后会生成相应的帮助文件(.hlp)和帮助标志头文件(.hlp.hrh)。在应用中程序会根据用户选择调用CCoeAppUi::AppHelpContextL, 之后系统会利用帮助标志作为参数调用被覆盖的CCoeAppUI::HelpContextL或CCoeControl::GetHelpContext方法从帮助文件中获取该标志所标识的帮助内容,再通过HlpLauncher::LaunchHelpApplicationL显示相应的帮助。 那怎样本地化帮助呢?根据本地化的一般方法,开发者必须为不同的语种建立不同的帮助,也就是为同一帮助项建立不同语种的内容。众所周知,系统必须通过帮助标志才能在帮助文件中找到相应的帮助内容。而帮助标志是什么?从帮助标志头文件中可以获知,它们其实是上下文的字串描述符,也就是一些字串。基于以上情况,我们完全可以舍弃帮助标志头文件,而直接在资源文件中建立相应的帮助标志字串资源,模仿%EPOCROOT%\Series60Ex\language\这个例程,通过本地化帮助标志字串,来实现上下文相关帮助的本地化。 下面就以Series 60 2nd Edition SDK for Symbian OS Supporting Feature Pack 3 for C++中大家所熟知的例程Help Example为基础(之所以选择这个SDK是因为其支持简体中文),对其进行中文简体本地化,籍此来谈谈上下文相关帮助的本地化。 首先,为不同语种建立不同的帮助源文件,即.rtf文件,用不同的帮助标志作为区别。将%EPOCROOT%\Series60Ex \helpexample\help\下的helpexample.rtf更名为helpexample01.rtf,内容作如下修改(主要是帮助标志): Code:
Author: Nokia Date: 23 July 2002 Version: 1 HelpExample 0x10005B93 Application Help ¢ ContextApplication01 The Application i HelpExample Application When there are no controls in focus with help available, this message is shown. Helpful Form ¢ ContextHelpfulForm01 The form i HelpExample Form This is a form implementing context-sensitive help. Special help is available when the first two controls have focus. This message is shown otherwise. Edwin 1 ¢ ContextEdwin101 Control 1 on form i HelpExample Edwin 1 This is help for the first control on the form. Edwin 2 ¢ ContextEdwin201 Control 2 on form i HelpExample Edwin 2 This is help for the second control on the form. Code:
Author: Nokia Date: 23 July 2002 Version: 1 HelpExample 0x10005B93 应用帮助 ¢ ContextApplication31 The Application i 帮助示例应用 当获得焦点的控制没有可用帮助时显示此信息。 帮助表格 ¢ ContextHelpfulForm31 The form i 帮助示例表格 这是一个执行上下文相关帮助的表格。当前两个控制获得焦点时会有相应的帮助。此信息在例外的情况下显示。 编辑框一 ¢ ContextEdwin131 Control 1 on form i 帮助示例编辑框一 这是表格中控制一的帮助。 编辑框二 ¢ ContextEdwin231 Control 2 on form i 帮助示例编辑框二 这是表格中控制二的帮助。 Code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml:stylesheet href="..\..\..\epoc32\tools\cshlpcmp\xsl\CSHproj.xsl" title="CS-Help project" type="text/xsl"?>
<!DOCTYPE cshproj SYSTEM "..\..\..\epoc32\tools\cshlpcmp\dtd\cshproj.dtd">
<cshproj>
<helpfileUID>0x10005B94</helpfileUID>
<directories>
<input></input>
<output></output>
<graphics>pictures/</graphics>
<working></working>
</directories>
<files>
<source>
<file>HelpExample01.rtf</file>
<file>HelpExample31.rtf</file>
</source>
<destination>HelpExample.hlp</destination>
<customization>custom.xml</customization>
</files>
</cshproj>
接着修改%EPOCROOT%\Series60Ex \helpexample\Group\helpexample.mmp Code:
/* Copyright (c) 2004, Nokia. All rights reserved */ TARGET HelpExample.app TARGETTYPE app UID 0x100039CE 0x10005B93 TARGETPATH \system\apps\helpexample . . . SOURCEPATH ..\help DOCUMENT HelpExample01.rtf DOCUMENT HelpExample31.rtf DOCUMENT HelpExample.cshlp DOCUMENT Custom.xml . . . LIBRARY euser.lib LIBRARY apparc.lib LIBRARY cone.lib LIBRARY eikcore.lib LIBRARY avkon.lib LIBRARY eikdlg.lib LIBRARY eikcoctl.lib LIBRARY hlplch.lib LANG 01 31 AIF HelpExample.aif ..\aif HelpExampleAif.rss c12 qgn_help_demo_cxt.bmp qgn_help_demo_cxt_mask.bmp qgn_help_demo_lst.bmp qgn_help_demo_lst_mask.bmp |
|
因为不再使用帮助标志头文件HelpExample.hlp.hrh,所以%EPOCROOT%\Series60Ex \helpexample\data\中的helpexample.rss必须加入新的帮助标志字串资源,%EPOCROOT%\Series60Ex \helpexample\data\helpexample.rss
Code:
/* Copyright (c) 2004, Nokia. All rights reserved */
NAME HELP
// INCLUDES
#include <eikon.rh>
#include <avkon.rh>
#include <avkon.rsg>
#include "HelpExample.hrh"
#include "HelpExample.loc"
// RESOURCE DEFINITIONS
// ----------------------------------------------------------------------------
//
// Define the resource file signature
// This resource should be empty.
//
// ----------------------------------------------------------------------------
//
RESOURCE RSS_SIGNATURE {}
.
.
.
RESOURCE DIALOG r_helpful_dialog
{
.
.
.
}
// ----------------------------------------------------------------------------
//
// r_helpful_dialog_form
// Form with three entries, 2 of which will provide context
// sensitive help
//
// ----------------------------------------------------------------------------
//
RESOURCE FORM r_helpful_dialog_form
{
items =
{
.
.
.
};
}
//帮助标志字串资源
RESOURCE TBUF32 r_kca { buf=qtn_kca; }
RESOURCE TBUF32 r_kce1 { buf=qtn_kce1; }
RESOURCE TBUF32 r_kce2 { buf=qtn_kce2; }
RESOURCE TBUF32 r_kchf { buf=qtn_kchf; }
之后通过同一目录的字串文件实现帮助标志字串的本地化,将helpexample.loc另存为helpexample.l01并修改为: Code:
/* Copyright (c) 2004, Nokia. All rights reserved */ // LOCALISATION STRINGS // MENU TEXTS //d:Command in options list. //d:Show form. #define qtn_help_helpexample_ShowForm "Show Form" //d:Command in options list. //d:Help. #define qtn_help_helpexample_Help "Help" //d:Command in options list. //d:Exit. #define qtn_help_helpexample_Exit "Exit" // OPTIONS TEXTS IN VIEWING FORM //d: Menu for "Options" when in viewing form //d: Help #define qtn_help_helpexample_ViewHelp "Help" //d:Caption string for app. #define qtn_help_caption_string "Help Example" //d:Short caption string for app. #define qtn_help_short_caption_string "Help" // d:Dialog Form. // d: Names listed in Dialog. #define qtn_help_dialog1_prompt "Edwin 1" #define qtn_help_dialog2_prompt "Edwin 2" #define qtn_help_dialog3_prompt "Edwin 3" //帮助标志字串 #define qtn_kca "ContextApplication01" #define qtn_kce1 "ContextEdwin101" #define qtn_kce2 "ContextEdwin201" #define qtn_kchf "ContextHelpfulForm01" // End of File Code:
/* Copyright (c) 2004, Nokia. All rights reserved */ // LOCALISATION STRINGS // MENU TEXTS //d:Command in options list. //d:Show form. #define qtn_help_helpexample_ShowForm "显示表格" //d:Command in options list. //d:Help. #define qtn_help_helpexample_Help "帮助" //d:Command in options list. //d:Exit. #define qtn_help_helpexample_Exit "退出" // OPTIONS TEXTS IN VIEWING FORM //d: Menu for "Options" when in viewing form //d: Help #define qtn_help_helpexample_ViewHelp "帮助" //d:Caption string for app. #define qtn_help_caption_string "帮助示例" //d:Short caption string for app. #define qtn_help_short_caption_string "帮助" // d:Dialog Form. // d: Names listed in Dialog. #define qtn_help_dialog1_prompt "编辑框一" #define qtn_help_dialog2_prompt "编辑框二" #define qtn_help_dialog3_prompt "编辑框三" //帮助标志字串 #define qtn_kca "ContextApplication31" #define qtn_kce1 "ContextEdwin131" #define qtn_kce2 "ContextEdwin231" #define qtn_kchf "ContextHelpfulForm31" // End of File Code:
/* Copyright (c) 2004, Nokia. All rights reserved */ CHARACTER_SET UTF8 #ifdef LANGUAGE_01 #include "helpexample.l01" #endif #ifdef LANGUAGE_31 #include "helpexample.l31" #endif // End of File %EPOCROOT%\Series60Ex \helpexample\src\helpexampleappui.cpp Code:
/* Copyright (c) 2004, Nokia. All rights reserved */
// INCLUDE FILES
#include <e32std.h>
#include <hlplch.h>
#include <Helpexample.rsg>
#include "HelpExample.pan"
#include "HelpExampleAppUi.h"
#include "HelpExampleAppView.h"
#include "HelpExampleApplication.h"
#include "HelpExample.hrh"
#include "HelpfulForm.h"
//#include "HelpExample.hlp.hrh"
.
.
.
// -----------------------------------------------------------------------------
// CArrayFix <TCoeHelpContext>
// Return the help context for this application.
// -----------------------------------------------------------------------------
//
CArrayFix <TCoeHelpContext>* CHelpExampleAppUi::HelpContextL() const
{
CArrayFixFlat <TCoeHelpContext>* array =
new ( ELeave )CArrayFixFlat <TCoeHelpContext> ( 1 );
CleanupStack::PushL( array );
HBufC16* p = iEikonEnv->AllocReadResourceLC( R_KCA );
array->AppendL( TCoeHelpContext( KUidHelpExampleApp, (TBufC16<32>) *p ) );
CleanupStack::PopAndDestroy( p );
CleanupStack::Pop( array );
return array;
}
// End of File
Code:
/* Copyright (c) 2004, Nokia. All rights reserved */
// INCLUDE FILES
#include <AknAppUi.h>
#include <Avkon.rsg>
#include <eikmenup.h>
#include <Helpexample.rsg>
#include "HelpfulForm.h"
#include "HelpExampleApplication.h"
#include "HelpExample.hrh"
//#include "HelpExample.hlp.hrh"
.
.
.
// -----------------------------------------------------------------------------
// CHelpfulForm::GetHelpContext()
// Gets the control's help context. Returns a NULL context by default.
// -----------------------------------------------------------------------------
//
void CHelpfulForm::GetHelpContext( TCoeHelpContext& aContext ) const
{
// Get any special help context for the control with focus, else a default
aContext.iMajor = KUidHelpExampleApp;
switch ( IdOfFocusControl() )
{
case EHelpExampleEdwin1:
// Provide special help context if first control has focus
{
HBufC16* pce1 = iEikonEnv->AllocReadResourceLC( R_KCE1 );
aContext.iContext = (TBufC16<32>) *pce1;
}
break;
case EHelpExampleEdwin2:
// Provide special help context if second control has focus
{
HBufC16* pce2 = iEikonEnv->AllocReadResourceLC( R_KCE2 );
aContext.iContext = (TBufC16<32>) *pce2;
}
break;
default:
// Provide default help context for this dialog otherwise
{
HBufC16* pchf = iEikonEnv->AllocReadResourceLC( R_KCHF );
aContext.iContext = (TBufC16<32>) *pchf;
}
break;
}
CleanupStack::PopAndDestroy( 1 );
}
.
.
.
// End of File
Code:
;/* Copyright (c) 2004, Nokia. All rights reserved */ ; Installation file for HelpExample application ; HelpExample.pkg ; ;Language - standard language definitions &EN ;Standard SIS file header #{"HelpExample"},(0x10005B93),1,0,0 ;Supports Series 60 v 2.0 (0x101F7960), 0, 0, 0, {"Series60ProductID"} ; "..\..\..\epoc32\release\thumb\urel\HelpExample.APP" -"!:\system\apps\HelpExample\HelpExample.app" "..\..\..\epoc32\data\z\system\apps\HelpExample\HelpExample.r01" -"!:\system\apps\HelpExample\HelpExample.r01" "..\..\..\epoc32\data\z\system\apps\HelpExample\HelpExample.r31" -"!:\system\apps\HelpExample\HelpExample.r31" "..\help\HelpExample.hlp" -"!:\system\help\helpexample.hlp" "..\..\..\epoc32\data\z\system\apps\HelpExample\HelpExample_caption.r01" -"!:\system\apps\HelpExample\HelpExample_caption.r01" "..\..\..\epoc32\data\z\system\apps\HelpExample\HelpExample_caption.r31" -"!:\system\apps\HelpExample\HelpExample_caption.r31" "..\..\..\epoc32\data\z\system\apps\HelpExample\HelpExample.aif" -"!:\system\apps\HelpExample\HelpExample.aif" 谢谢各位!请开发伙伴们批评指正! ![]() |
|
S60平台本身支持上下文相关帮助的本地化,所以最简的步骤是:
1. 做好英文版的HLP文件 2. 拷贝RTF文件并翻译成其它语种(帮助标识不变),并生成HLP文件 3. 将帮助文件的后缀按其语种改为h01和h31等 4. 打包 |
| chenziteng |
| View Public Profile |
| Find all posts by chenziteng |
|
其实起初我的做法和你说的相同,但一直没能成功。
阁下可以具体讲讲吗? 在下愚钝,敬请赐教! 谢谢! ![]() |
|
步骤如前所述,就是常规的使用方法。
我在"S60 2nd Edition SDK"的Emulator和真机(6600)上用过,可行。再往后在"S60 2nd Edition SDK FP3"的Emulator和真机(N90)上也用过,所以推测2.x上都能这么用。 1.x的没试过,但我猜也行。 |
| chenziteng |
| View Public Profile |
| Find all posts by chenziteng |
|
Quote:
|
| DZD_wangchao |
| View Public Profile |
| Find all posts by DZD_wangchao |
|
"A picture is worth a thousand words", so see the simple example.
"Qumjlxvo(LocalizedCSHelp).zip" http://wiki.forum.nokia.com/index.ph...zedCSHelp).zip
Last edited by chenziteng : Yesterday at 17:51.
Reason: fixed a broken link
|
| chenziteng |
| View Public Profile |
| Find all posts by chenziteng |
|
在chenziteng的提示下,发现本人原先的上下文相关帮助本地化方案是可行的。
下面以原始的Help Example为例进行上下文相关帮助的本地化。 首先,建立中文简体的帮助源文件,帮助标志不变,将%EPOCROOT%\Series60Ex \helpexample\help\下的helpexample.rtf另存为helpexample31.rtf,内容如下: Code:
Author: Nokia Date: 23 July 2002 Version: 1 HelpExample 0x10005B93 应用帮助 ¢ ContextApplication The Application i 帮助示例应用 当获得焦点的控制没有可用帮助时显示此信息。 帮助表格 ¢ ContextHelpfulForm The form i 帮助示例表格 这是一个执行上下文相关帮助的表格。当前两个控制获得焦点时会有相应的帮助。此信息在例外的情况下显示。 编辑框一 ¢ ContextEdwin1 Control 1 on form i 帮助示例编辑框一 这是表格中控制一的帮助。 编辑框二 ¢ ContextEdwin2 Control 2 on form i 帮助示例编辑框二 这是表格中控制二的帮助。 Code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml:stylesheet href="..\..\..\epoc32\tools\cshlpcmp\xsl\CSHproj.xsl" title="CS-Help project" type="text/xsl"?>
<!DOCTYPE cshproj SYSTEM "..\..\..\epoc32\tools\cshlpcmp\dtd\cshproj.dtd">
<cshproj>
<helpfileUID>0x10005B94</helpfileUID>
<directories>
<input></input>
<output></output>
<graphics>pictures/</graphics>
<working></working>
</directories>
<files>
<source>
<file>HelpExample31.rtf</file>
</source>
<destination>HelpExample.h31</destination>
<customization>custom.xml</customization>
</files>
</cshproj>
接着修改%EPOCROOT%\Series60Ex\helpexample\group\下的supplementary.mk: Code:
makmake : cshlpcmp ..\help\HelpExample.cshlp cshlpcmp ..\help\HelpExample31.cshlp ifeq (WINS, $(findstring WINS, $(PLATFORM))) copy ..\help\HelpExample.hlp ..\..\..\epoc32\$(PLATFORM)\c\system\help copy ..\help\HelpExample.h31 ..\..\..\epoc32\$(PLATFORM)\c\system\help endif clean : del ..\help\HelpExample.hlp del ..\help\HelpExample.hlp.hrh del ..\help\HelpExample.h31 del ..\help\HelpExample.h31.hrh bld : cshlpcmp ..\help\HelpExample.cshlp cshlpcmp ..\help\HelpExample31.cshlp ifeq (WINS, $(findstring WINS, $(PLATFORM))) copy ..\help\HelpExample.hlp ..\..\..\epoc32\$(PLATFORM)\c\system\help copy ..\help\HelpExample.h31 ..\..\..\epoc32\$(PLATFORM)\c\system\help endif freeze lib cleanlib final resource savespace releasables : Code:
/* Copyright (c) 2004, Nokia. All rights reserved */ TARGET HelpExample.app TARGETTYPE app UID 0x100039CE 0x10005B93 TARGETPATH \system\apps\helpexample . . . SOURCEPATH ..\help DOCUMENT HelpExample.rtf DOCUMENT HelpExample31.rtf DOCUMENT HelpExample.cshlp DOCUMENT HelpExample31.cshlp DOCUMENT Custom.xml . . . LIBRARY euser.lib LIBRARY apparc.lib LIBRARY cone.lib LIBRARY eikcore.lib LIBRARY avkon.lib LIBRARY eikdlg.lib LIBRARY eikcoctl.lib LIBRARY hlplch.lib LANG 01 31 AIF HelpExample.aif ..\aif HelpExampleAif.rss c12 qgn_help_demo_cxt.bmp qgn_help_demo_cxt_mask.bmp qgn_help_demo_lst.bmp qgn_help_demo_lst_mask.bmp 再将helpexample.l01用UTF-8编码另存为helpexample.l31,写入简体中文字串: Code:
/* Copyright (c) 2004, Nokia. All rights reserved */ // LOCALISATION STRINGS // MENU TEXTS //d:Command in options list. //d:Show form. #define qtn_help_helpexample_ShowForm "显示表格" //d:Command in options list. //d:Help. #define qtn_help_helpexample_Help "帮助" //d:Command in options list. //d:Exit. #define qtn_help_helpexample_Exit "退出" // OPTIONS TEXTS IN VIEWING FORM //d: Menu for "Options" when in viewing form //d: Help #define qtn_help_helpexample_ViewHelp "帮助" //d:Caption string for app. #define qtn_help_caption_string "帮助示例" //d:Short caption string for app. #define qtn_help_short_caption_string "帮助" // d:Dialog Form. // d: Names listed in Dialog. #define qtn_help_dialog1_prompt "编辑框一" #define qtn_help_dialog2_prompt "编辑框二" #define qtn_help_dialog3_prompt "编辑框三" // End of File Code:
/* Copyright (c) 2004, Nokia. All rights reserved */ CHARACTER_SET UTF8 #ifdef LANGUAGE_01 #include "helpexample.l01" #endif #ifdef LANGUAGE_31 #include "helpexample.l31" #endif // End of File Code:
;/* Copyright (c) 2004, Nokia. All rights reserved */ ; Installation file for HelpExample application ; HelpExample.pkg ; ;Language - standard language definitions &EN ;Standard SIS file header #{"HelpExample"},(0x10005B93),1,0,0 ;Supports Series 60 v 2.0 (0x101F7960), 0, 0, 0, {"Series60ProductID"} ; "..\..\..\epoc32\release\thumb\urel\HelpExample.APP" -"!:\system\apps\HelpExample\HelpExample.app" "..\..\..\epoc32\data\z\system\apps\HelpExample\HelpExample.r01" -"!:\system\apps\HelpExample\HelpExample.r01" "..\..\..\epoc32\data\z\system\apps\HelpExample\HelpExample.r31" -"!:\system\apps\HelpExample\HelpExample.r31" "..\help\HelpExample.hlp" -"!:\system\help\helpexample.hlp" "..\help\HelpExample.h31" -"!:\system\help\helpexample.h31" "..\..\..\epoc32\data\z\system\apps\HelpExample\HelpExample_caption.r01" -"!:\system\apps\HelpExample\HelpExample_caption.r01" "..\..\..\epoc32\data\z\system\apps\HelpExample\HelpExample_caption.r31" -"!:\system\apps\HelpExample\HelpExample_caption.r31" "..\..\..\epoc32\data\z\system\apps\HelpExample\HelpExample.aif" -"!:\system\apps\HelpExample\HelpExample.aif" 十分感谢chenziteng的帮助! 同时为一开始误导大家感到非常抱歉! 最后谢谢各位开发伙伴! ![]()
Last edited by r60600 : 2006-06-04 at 16:11.
|
|
本人初学者 有2个很小的问题 想请问
.pkg中的 ; Language 不用设置么? 还有 .loc .l01 .l31这3个文件是如何来的?为什么叫 l01 l31呢? 为什么要有这两个01 31呢? |
|
1、设置呀,如:
;Languages &EN 2、.l01 .l31. loc都是自己命名的本地化资源文件,可以采用其他扩展名,这些都无所谓的,只要包含该文件时正确写对名称即可。 I'd just be the catcher in the rye hoolee |
|
这个是有规则的,例如 r31代表简体中文,r01代表英文.
|
|
我的方法是直接做两个hlp文件后用同一个hrh就可以了,然后hlp文件用两个不同的UID,在l01和l31里便记录下UID,到时候读取的时候直接用UID读取就行了。
|
|
Quote:
|
|
查看prel的版本,要5.6xxx的那个版本.
5.8的不行. |
|
perl 已经改了 英文的可以生成 阿
|
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |