A method of implementing multi-language interface in ASP.net 2.0

Source: Internet
Author: User

1. Do the same interface as before, just note that all the text needs to have a multilingual interface to do with the label

2. When you're done, select this file in Solution Explorer and choose tools->generate Local Resource

3. You will find that a directory has been generated, app_localresources, and a ResX file in this directory. For example, if your ASPX file is default.aspx, it generates a file called Default.aspx.resx.

4. Open this file to see, the original in the label of those words are running here

5. Open the original ASPX file to see source, you will find that the source has changed:

<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Default2" title="Untitled Page" Culture="auto" meta:resourcekey="PageResource1" UICulture="auto" %>
…………
<asp:Localize ID="Localize1" runat="server" meta:resourcekey="Localize1Resource1"></asp:Localize>
*********************************************************************< /CODE>

If the text is on another control, it is basically automatically generated. such as the button and the GridView:

<asp:Button ID="Button1" runat="server" meta:resourcekey="Button1Resource1" Text="Button1" /><br />
<asp:GridView ID="GridView1" runat="server" meta:resourcekey="GridView1Resource1">
<Columns>
<asp:BoundField HeaderText="Header1" meta:resourcekey="BoundFieldResource1" />
<asp:BoundField HeaderText="Header2" meta:resourcekey="BoundFieldResource2" />
</Columns>
</asp:GridView>

The generated resource are as follows:

******************************************************************* **

6. Note here: meta:resourcekey= "PageResource1" and meta:resourcekey= "Localize1resource1" This means that the text here is read from the resource.

7. OK now to do a resource file for another language. Very simple, copy Default.aspx.resx again paste, then rename for Default.aspx.fr-fr.resx notice FR-FR is the name of the language you want to do. If you look at DVDRip, you should think it's like a subtitle file, right?

8. Some people say how do I know what the name of that language is? Very simply, open ie,tools->internet options-> Languages-> Add, the box is in the middle.

9. Now start editing the text for another resource. Open Default.aspx.fr-fr.resx, contrast the original content, the contents of the inside into French.

10. So far, we have completed the first phase. Asp. NET selects the displayed language according to the user's language preference. To change the settings in IE, in the place we have just said changed into FR-FR, open this page to see? If it's French, congratulations. If not, go back and redo ...

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.