Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to support other languages in Flex internationalization

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you "Flex internationalization how to support other languages", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how Flex internationalization supports other languages" this article.

Flex internationalization

Internal Flex internationalization files / libraries only support en_US,ja_JP localization, so if you want to support Chinese or other languages in Flex, you need to do something extra:

1. First, add new localization support, such as zh_CN, using the following methods:

From the command line, go to {FlexBuilder's installation directory} / sdks/3.0.0/bin directory, and run the command: copylocaleen_USzh_CN

The format of the command is (copylocaleoriginal_localenew_locale)

2. Add a directory at the same level as src in the Flex project to place localization files, such as:

The content in message.properties is as follows (in Chinese):

Note: the locale folder must be at the same level as the src directory.

3. Then add the following compiled items to the FlexCompiler of the project:

4. Using localization files, there are two ways to use localization files in Flex internationalization:

*: use @ Resource directly. Examples are as follows:

Where key indicates that the key,bundle of the resource to be fetched represents the localization file, and the name after .properties is removed.

Second: use ResourceManager to obtain. When using ResourceManager, you first need to specify the metadata of the resource file in AS or FLex, such as message.properties in the figure above, and add the following information:

[ResourceBundle ("message")]

You can use ResourceManager in MXML as follows:

Note: if you don't have the variable resourceManager in the container, you can use ResourceManager.getInstance () instead of resourceManager, because ResourceManager is monomorphic.

5. The next step is how to change the language at run time, as follows:

Actionscript code

PrivatefunctionchangeLanguage (): void {LocaleUtil.getInstance () .changeLocale ();} privatefunctionchangeLanguage (): void {LocaleUtil.getInstance () .changeLocale ();}

The relevant codes of LocaleUtil are as follows:

Actionscript code

PublicfunctionchangeLocale (): void {_ currentLanguage_currentLanguage=_currentLanguage== "zh_CN"? "en_US": "zh_CN"; ResourceManager.getInstance (). LocaleChain= [_ currentLanguage];} publicfunctionchangeLocale (): void {_ currentLanguage_currentLanguage=_currentLanguage== "zh_CN"? "en_US": "zh_CN"; ResourceManager.getInstance (). LocaleChain= [_ currentLanguage];}

This modifies the language of the Flex internationalization runtime. The effect is as follows:

After clicking "English", it will switch to the following effect.

After clicking "Chinese", you will return to the Chinese interface.

The above is all the content of the article "how does Flex internationalization support other languages"? thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report