Implementation of s60 3rd resource localization

Source: Internet
Author: User

Previously, a feisoon project was developed based on s60 2nd. Now we need to port s60 3rd to support Chinese characters, so we need to implement program localization. Chinese localization is still quite troublesome, and some friends often encounter the same problem. Therefore, I have recorded my localization implementation process and shared it with you. What's wrong, I hope to add more comments.

First, let's take a look at the s60 resource-related knowledge. The following documents are required. RSS is a resource source file; HDR is a file that defines localized strings, including the resource source file; RH resource header file, including the resource source file; HRH common C ++ header file, it is included in various source files. The resource header file output by the RSG resource compiler is generally referenced in the CPP file; the resource file after RSC compilation; the AIF is the application information file; before os8.0, use the AIF file to customize the application information. In os8.0, the application is compatible with the AIF and registration files. In os9.0, only registration files are supported. The registration file is the resource source file with the suffix _ reg added in the project. The general file name is appname_reg.rss. The so-called localization means that the source file of the RSS resource supports two or more languages after compilation. Here, we use the built-in helloworldbasic classic routine to implement Chinese localization.

If the program does not perform localization, the RSC file is generated after the RSS file is compiled. If the program implements localization, that is, the support for multiple languages is added to the MMP file. For example, to support both the English and Chinese languages, you need to implement the following in the file for name-based fear of MMP.

Start resource helloworldbasic. RSS
Header
Targetpath resourceapps
Lang 01 31
End // Resource

During re-compilation, two localized resource files helloworldbasic. R01 and helloworldbasic. R31 are generated. This is the first step of localization.

Next, you need to define the localized string, and then you will use the recursive file. The recursive file is very simple, that is, it stores the localized strings. Here we create two recursive files. At this time, we all understand that one is English, and the other is Chinese. Here we define two file names: helloworldbasic01.rls; helloworld31.rls.

The English content is as follows:

/**//*
* ===================================================== ========================================================
* Name: helloworldbasic01.rls
* Part of: helloworldbasic
* Interface:
* Description:
* Version:
*
* Copyright (c) 2005-2006 Nokia Corporation.
* This material, including documentation and any related
* Computer programs, is protected by copyright controlled
* Nokia Corporation.
* ===================================================== ========================================================
*/

// Localisation strings

// D: caption string for app.
Rls_string string_hewb_caption_string "helloworld"

// D: Short caption string for app.
Rls_string string_hewb_short_caption_string "HW"

// D: first item in "options" menu pane, "hello" event.
Rls_string string_hewb_command1 "hello"

// D: second item in "options" menu pane, "exit" event.
Rls_string string_hewb_command2 "hello from file"

// D: third item in "options" menu pane, "exit" event.
Rls_string string_hewb_exit "exit"

// D: when user requests ehelloworldbasiccommand1 event, text below is shown.
Rls_string string_hewb_command1_text "Hello! "

Rls_string string_helloworldbasic_loc_resource_file_1 "/resource/apps/helloworldbasic"

// End of File

The Chinese content is as follows:

/**//*
* ===================================================== ========================================================
* Name: helloworldbasic31.rls
* Part of: helloworldbasic
* Interface:
* Description:
* Version:
*
* Copyright (c) 2005-2006 Nokia Corporation.
* This material, including documentation and any related
* Computer programs, is protected by copyright controlled
* Nokia Corporation.
* ===================================================== ========================================================
*/

// Localisation strings
Character_set utf8

// D: caption string for app.
Rls_string string_hewb_caption_string "routine"

// D: Short caption string for app.
Rls_string string_hewb_short_caption_string "HW"

// D: first item in "options" menu pane, "hello" event.
Rls_string string_hewb_command1 "show you"

// D: second item in "options" menu pane, "exit" event.
Rls_string string_hewb_command2 ""

// D: third item in "options" menu pane, "exit" event.
Rls_string string_hewb_exit "exit"

// D: when user requests ehelloworldbasiccommand1 event, text below is shown.
Rls_string string_hewb_command1_text "Hello! "

Rls_string string_helloworldbasic_loc_resource_file_1 "/resource/apps/helloworldbasic"

// End of File

The content of these two files can be understood at a glance. Note that UTF-8 encoding is required for string files localized in Chinese symbain. If you read the above Code, you will see the "character_set utf8" line of code. This indicates that the file uses utf8 encoding. If other encoding is used, garbled characters are displayed in the program, rather than Chinese characters. Utf8 file production can be achieved using some tools. My practice is to create a TXT file. The TXT file is encoded as gb2312, And the charconv tool is used to convert the file to utf8. The specific commands are as follows:

Charconv-input = gb2312 helloworldbasic_loc.rls-output = utf8 helloworldbasic31.rls

Finally, you need to reference different files in the RSS resource source file based on the language environment. The predefined macro is used here. Language_01 and language_31 indicate that the current system is an English or Chinese system, and different string definition files are selected based on different systems.

# Ifdef required age_01
# Include "helloworldbasic01.rls"
# Elif defined when age_31
# Include "helloworldbasic31.rls"
# Endif

Now, compile and run the program and you will see a typical Chinese helloworldbasic program.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.