How to Localize the Static Content (Copyright and Disclaimer Information) in a ASP.NET Web Application

By
Hi Friend, You already know,we can generate resources for server control properties by using implicit and explicit localization expressions.To implement localization concepts in a web application,we need to localize the following elements:-
  • HTML Control 
  • Static Content
HTML Control :-
HTML Controls can not be localized using implicit or explicit expression,unless they are running on the server.If we want to run HTML control on the server, we have to to include the runat ="server" attribute in the @page directive, After the HTML controls are marked as server controls,local resources are automatically generated for the localizable properties,such as for the Tool Tip and Text properties of the controls. Now We can be bound HTML server controls using implicit or explicit expressions concepts.
Static Content :-We can use the localization expressions concepts to localize the properties of controls used on a web page.You already know ,There are some static contents used on ASP.NET web application,such as Copyright information or Disclaimer information..NET Framework  is allowed to localize the static contents of the web page,such as <Localize runat = "Server"> tag.We we can implement both concepts in a ASP.NET web application easily as given below:-

Step 1:-First open your Visual studio-->File-->New -->Website-->Select ASP.NET Empty Website-->OK-->Now open Solution Explorer Window-->Add a New Web page (Default.aspx)--> Now Open Source file-->Write the Culture="auto" and UICulture="auto" in @ page directive as shown below:-

Step 2:-Now Drag and Drop Label control on the page (default.aspx) from the ToolBox as shown below:-

Step 3:-Now open Solution Explorer Window-->Right click on project(static content localization)-->Select Add ASP.NET Folder--> Press  App_GlobalResources-->You will see that one folder (App_GlobalResources) will be added in your Solution Explorer Window  as shown below:-

Step 4:- Now Right Click on App_GlobalResources folder--> Add New Item..--> Select Resource file-->Write the file name default.resx -->press Add button as shown below:-
Step 5:-Now Add some other resource files like default.fr.resx and default.ur.resx as shown below:-  

Note:-Here ,i have given a demo, you have to add other countries language resource files according to your requirements.
Step 6:-Now Double Click on Default.resx file --> Write the Name and Value Fields as shown below:-

Note:-Here, Default.resx file is used for English(US) country.Suppose you your web page is accessing from  Iran and you have not added the resource file for Iran country for localization purpose then this default.resx file is used to Localize the data in English(US) language.There are different codes for each country ,you can see it in Browsers or google translator.  
Step 7:-Now Double Click on Default.ur.resx file --> Write the Name and Value Fields as shown below:-

Note:- Suppose, you have not know about URDU language then how to add your value field contents,this is a problem for you because Nobody Know every languages, So here you have to Use Google Translator for translate one language to another languages.
Step 8:-Now Double Click on Default.fr.resx file --> Write the Name and Value Fields as shown below:-

Step 9:- Now open Source file in your Default.aspx page--> Bind the HTML ,Body and Label controls Texts as given below:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Culture="auto" UICulture="auto" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html Id="Html1" runat="server" dir="<%$ Resources:default,TextDirection %>" xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Welcome to MY.NET Tutorials</title>
</head>
<body id="Body1" runat="server" dir="<%$ Resources:default,TextDirection %>">
    <form id="form1" runat="server">
    <div>
        <span class="style1"><strong>Welcome to MY.NET Tutorials</strong></span><br />
        <br />
        <asp:Label ID="Label1" runat="server" Text="<%$ Resources:default, msdotnet %>"></asp:Label>
    </div>
    </form>
</body>
</html>


Step 10:-Now Open Internet Explorer Browser-->Setting-->Internet options-->Go Languages-->Add Language -->OK-->Set the priority of the Language by Move Up and Move Down Arrow as shown below:-

Step 11:-Now Run the Application (press F5)-->Now set first priority of  French language in Browser as shown in step 10-->You will see following output as shown below:-  

Step 12:-Now again Run the Application (press F5)-->Now set first priority of  Urdu language in Browser -->You will see following output as shown below:-

Step 13:-Now again Run the Application (press F5)-->Now set first priority of  English(US) language in Browser -->You will see following output as shown below:-
For More...
  1. Learn Complete Web services in .NET with real life Examples
  2. Learn Complete WCF in .NET with real life Examples
  3. Learn Complete WPF  in .NET with real life Examples
  4. Object oriented programming in .net with examples
  5. Learn Crystal Reports with Examples
  6. How to make your media player and install it on your systems easily
  7. How to build a calculator and install it on your Computers easily
  8. Learn Complete .NET Interview Questions and Answers for job seekers
Download Whole Attached File
      Download

0 comments:

Post a comment

Powered by Blogger.