When asp.net hits JSF's internationalization of the application

Source: Internet
Author: User
Tags config key locale resource
Asp.net|js| program internationalization refers to the support of multiple languages and cultures in your application. This includes providing localized text messages and formats (such as dates) so that users in different parts of the world can view your Web pages in a format and language that they understand. This type of functionality is also becoming increasingly important as the global web continues to grow. We'll take a quick look at how each framework allows you to externalized page text (such as domain labels) to provide different localized support.

JSF applications that support different localization use the same implementation approach as other Java EE applications-by storing local text data in a resource bundle properties file. You will provide a property file for each localized support (each localization is marked with one language code and one country code (such as en-us). Switching the display language is actually a question of redirecting to another properties file. In the previous ASP.net release, it was cumbersome to support different localization in a asp.net application, but in ASP.net 2.0 there was considerable improvement in that area. For example, in ASP.net 2.0, there is no need to recompile when switching between different languages.

To enable the JSF application to support different localization capabilities, I added a webreservations.properties file to the application and implemented a support for en-US localization. The title of the subscription page is "Make a reservation for conference Room". I simply added a key/value pair to this resource-binding property file:

#示例ResourceBundle属性文件

Reserveroomteamlabel=reservation Team:

I can create any number of localized specific messages for the same component. Then I need to tell the application how to use this file-by adding the following statements to the Faces-config.xml file:

<message-bundle> webreservations.properties </message-bundle>
<locale-config>
<default-locale> en </default-locale>
!--Add Other locales here.-->
</locale-config>
By referencing a resource bundle, you can use a reference to this key instead of the text in the JSF callout. Here's an example:

<ui:label binding= "#{reserveroom.lblreserveteam}" id= Lblreserveteam "style=" LEFT:48PX; top:96px; Position:absolute "text=" #{messages. Reserveroomteam} "/>
Asp. NET provides resource file support for different localization. These resource files all have an extension. resx. Resource expressions are introduced in ASP.net 2.0-you can put them in asp.net annotations. These expressions look similar to asp.net data-binding expressions. Note that developers can specify both local and global resources for an application together. In this example, I created a local resource file to correspond to the new reservation page.

Local resources need to be placed under a folder "App_LocalResources". Each file under this folder should have a name similar to "{aspx page Name}].aspx.resx". I created a file Reservations.aspx.resx. In this file, I added an entry for "Reservation team:" As I did in the JSF application. To enable the page to access these resources and to give the label the same text at run time, you can add the following expression:

<asp:label id= "Tea" runat= "Server" text=<%$ Resources:reservationsteamlabel%>> </asp:Label>

Asp. net-to add localized text

jsf-to add localized text
If you have not yet developed an application that implements internationalization requirements, you will likely do so in the future. However, this is easy to do either with JSF or with asp.net.

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.