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 understand the Analysis of ASP.NET Multi-language support components

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

Share

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

This article introduces you how to understand the analysis of ASP.NET multi-language support components, the content is very detailed, interested friends can refer to, hope to be helpful to you.

In fact, ASP.NET has integrated support for internationalization and localization, but I happened to be working on CS a few days ago. So instead of using Microsoft's built-in multilingual support program, it is rewritten based on the multilingual support solution of the CS2.1 project.

It is mainly realized by the interaction between ASP.NET multi-language support components and site engineering.

one。 Component Engineering:

The ResourceManager object is responsible for reading the resource (text), and the Ryu666Cache object is responsible for caching the resource file data (adding cache dependencies).

two。 Site project:

The ASP.NET multilingual support component has two main responsibilities: one is to provide all language versions of resource files (XML) in the Languages directory under the site directory. Second, the default language version of the site is provided in the appSettings section of the Web.Config file. Instructions for use:

According to the above instructions, in fact, the use of this module is quite simple, aiming at the following aspects:

1. Resource reads:

Call ResourceManager.GetString ("XXXX") where you need to read the resource text, and XXXX is the name attribute of the resource element in the resource file. Special reminder: it is not necessary to read resources in the site project, this component will be more effective if you use custom controls.

two。 The resource file provides:

Create a Languages directory in the site project, and then declare all supported language versions in the languages.xml in it. Then create a subdirectory with the name of the corresponding language code, and then create the Resources.xml resource file in its own format.

3. Set the default site language:

Declare in the appSettings section of the Web.config file. Its value needs to correspond to the language code declared by languages.xml in the language directory.

4. User personalized language selection:

Set the Session ["userLanguage"] value where you need to switch the user's language. Setting the default site language is similar, with values that need to be defined in the language declaration file.

For the convenience of demonstration, Session is used to store the customized language version. If it is used in production, it is recommended to combine ASP.NET 2.0 Profile to manage the user's personalized language version. Using this ASP.NET multilingual support component, you can easily support multilingual internationalization in ASP.NET programs.

This is the end of the analysis on how to understand the multi-language support components of ASP.NET. I hope the above content can be of some help and learn more knowledge. If you think the article is good, you can share it for more people to see.

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: 222

*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