Two articles on how to implement multiple languages in flex Development

Source: Internet
Author: User

Article 1

 

Today, I searched online for the flex multi-language implementation method and found that there are many implementation methods.

The multi-language implementation method introduced here is not what I want, but it can also achieve general requirements. The following describes the implementation scheme of the multi-language used by me:

1) run the command in the command line

Locale en_us zh_cn (the en_us directory exists by default in the flex SDK directory. If you want to add other languages, you must manually add the Language Pack. The following example uses the Chinese Language Pack, so I add a zh_cn folder)

2) Create the resources/locale/en_us and resources/locale/zh_cn directories under the root directory of the Flex project.

3) In the flex Project

Right-click and choose Properties> Source Path> Add folder.

In the displayed input box, enter resources/locale/{locale}

(Note: The path here must be the same as the path created in step 2)

4) In the flex Project

Right-click and choose Properties> flex compiler.

In additional compiler arguments, enter-locale en_us zh_cn

(Note: you must add this command so that {locale} in step 3 can find the corresponding language file through this command)

5) Create the admin. properties file under en_us and zh_cn respectively (Note: use. properties as the file suffix)

Add Admin. Name = test_us to/en_us/admin. properties.

Add Admin. Name = test_cn to/zh_cn/admin. properties.

6) Create index. mxml

<? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Application
Xmlns: MX = "http://www.adobe.com/2006/mxml
"Layout =" vertical ">
<Mx: SCRIPT>
<! [CDATA [
Import MX. Resources. ResourceManager;

Private function changelocale (locale: string): void {

// Modify the language
ResourceManager. localechain = [locale];
}
]>
</MX: SCRIPT>
<Mx: Metadata>
[Resourcebundle ("admin")]
</MX: Metadata>
<Mx: applicationcontrolbar width = "400">
<Mx: Label text = "content" width = "100%"/>
<Mx: button label = "eng" Click = "changelocale ('en _ us')"/>
<Mx: button label = "ch" Click = "changelocale ('zh _ Cn)"/>
</MX: applicationcontrolbar>
<Mx: Text text = "{ResourceManager. getstring ('admin', 'admin. name')}" width = "400" Height = "240"/>
</MX: Application>

The running effect will not be posted at this moment. If you are interested, try it yourself .......

 

Article 2

How to implement multi-language flex


Create a locale directory under the project directory, and then create a directory for each country in the local directory, such as CH-GB, en_us, ja_jp,
Put a file in these directories named strings. properties. The content format key = value is as follows:
AAA = d
Bbb = C
CCC = B
Ddd =

Note: If the value is a Chinese character, it must be encoded in/u + unicode format. For example, the next value is/u4e0b/u4e00/u4e2a.

Usage

Private Static Var stringresources: resourcebundle;
[Bindable]
Private var VA: string;
[Bindable]
Private var VB: string;
[Bindable]
Private var VC: string;
[Bindable]
Private var VD: string;



Private function loadresources (): void
{
Va = stringresources. getstring ("AAA ");
VB = stringresources. getstring ("BBB ");
VC = stringresources. getstring ("CCC ");
Vd = stringresources. getstring ("DDD ");
}
Bind the VA, VB, Vc, and VD variables to the display.

Set in the project during compilation

Project --- properties ----- flex Compiler
Add in additional compiler arguments:
-Locale ch-GB

Related Article

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.