Switch between dynamic and local languages when the Symbian program is running

Source: Internet
Author: User
Contents

[Hide
]

  • 1
    Notes:
  • 2
    Procedure:

    • 2.1
      1) modify the Lang statement in the projectname. MMP file:
    • 2.2
      2) Modify multilingual resource compilation settings in the RSS File
    • 2.3
      3) Reload the tfilename cprojectapplication: resourcefilename () const Function
    • 2.4
      4) rewrite the constructor function of Appui.
    • 2.5
      5) load the initial resource file
    • 2.6
      6) force display status panel
    • 2.7
      7) switch local resources
    • 2.8
      8) Final constructor function of Appui
    • 2.9
      9) function definitions used

Notes:

Platform: s60 3rd.

Procedure:

1) modify the Lang statement in the projectname. MMP file:
In the carbide environment, the default Lang statement is written as follows:
LANG    SC
Modify:
LANG    01   31
Among them, 01 represents English, 31 represents Chinese (assuming only English and Chinese are supported)

 

2) Modify multilingual resource compilation settings in the RSS File

Because the program supports two languages, there should be two local resource files, which are assumed to be: langfile_01.rls and langfile_31.rls respectively. Langfile_01.rls contains all English strings, and langfile_31.rls contains all Chinese strings used.

Then, add the following statement to the RSS file:

#ifdef LANGUAGE_01
#include “LangFile_01.rls”
#endif

#ifdef LANGUAGE_31
#include “LangFile_31.rls”
#endif

Multilingual compilation mechanism: Lang statements support several languages, and the resource compiler will compile several localized resources by repeatedly compiling. RSS files. During the first compilation
Sentence: # ifdef
Language_01 takes effect. The RSS file contains the langfile_01.rls file and then generates the English resource file. R01. During the second compilation
# Ifdef language_01 takes effect. The RSS file includes the langfile_31.rls file and then generates the English resource file. R31.

3) Reload the tfilename cprojectapplication: resourcefilename () const Function

This function must be reloaded because the framework will call it before the createdocumentl () function during application initialization.
Resourcefilename () is used to return the name of the Application resource file. If this function is not reloaded in the program, the Framework automatically calls
The resourcefilename () function loads the default resource file to the control environment, so that we cannot switch the resource file during runtime, because the resource file
Parts have been completely handed over to system management, and developers are no longer allowed to intervene. If the program supports multiple languages, the resourcefilename () function uses
Baflutils: nearestlanguagefile () loads localized resource files suitable for the current language of the device into the control environment, which also causes the same problem. Total
The system automatically loads and manages resource files without reloading the resourcefilename () function.

(For the definition of overload functions, see Part 1 function definition)

4) rewrite the constructor function of Appui.

Enonstandardresourcefile must be passed to the baseconstructl () function, otherwise the application will automatically call
Readappinforesourcel () function, trying to set the standard
Import resource to application. However, the resourcefilename () function has been reloaded. The resource name is an empty string, so the actual
No resources are added to the program. Once executed, the panic is generated.

In addition, because the third-edition app supports the Scaling Mechanism, you must pass the eaknenableskin to the baseconstructl () function.

BaseConstructL( ENonStandardResourceFile|EAknEnableSkin );

5) load the initial resource file

If the current language is set to English, call:

_LIT(KReourse01,"//resource//apps//filename.r01");
iRscOffset = AddResourceFileL(KReourse01);

If the current language is set to Chinese, call:

_LIT(KReourse31,"//resource//apps// filename.r31");
iRscOffset = AddResourceFileL(KReourse31);

 

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.