简体   繁体   中英

How to add regional languages to our web page?

I refereed This Link 1 : how to use kannada font in asp.net? But i am unable to use the Kannada language in my page.I want to type Kannada in text box. 卡纳达语文本框 But it is not happening... can any one tell me what may be the reason for that?

My source code is here: forKannada.css file

  @font-face {font-family:RaghuKannada;
src: url('http://www.cdacmumbai.in/projects/indix/RaghuFonts/RORaghuKannada.ttf');}

home.aspx

 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Home.aspx.cs" nherits="Home"  Culture="kn-IN" UICulture="kn-IN" %>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//kn-IN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="kn">
 <head runat="server">
<title></title>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="../CSS/forKannada.css" rel="stylesheet" type="text/css" />    
</head>
<body>
<form id="form1" runat="server">
&nbsp;<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<br />
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
&nbsp;
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />    
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Kannada"Font-Names="Tunga" />
&nbsp;
</form>

</body>
</html>

Home.aspx.cs file

 public partial class Home : System.Web.UI.Page
 {
 ResourceManager rm;
 CultureInfo ci;
 static bool lkannda = false;
 protected void Page_Load(object sender, EventArgs e)
 {
 if (!IsPostBack)
 {
 Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
 rm = new     ResourceManager("Resources.Strings",System.Reflection.Assembly.Load("App_GlobalResources"))     ;
 ci = Thread.CurrentThread.CurrentCulture;
 LoadString(ci);
 }
 else
 {
 rm = new     ResourceManager("Resources.Strings",System.Reflection.Assembly.Load("App_GlobalResources")); 
 ci =Thread.CurrentThread.CurrentCulture;
 LoadString(ci);
 }
 }
 private void LoadString(CultureInfo ci)
 {
 Label1.Text = rm.GetString("Name", ci);
 Label2.Text = rm.GetString("Desc", ci);
 Button1.Text = rm.GetString("AboutMe", ci);
 }
 protected void Button1_Click(object sender, EventArgs e)
 {
 if(lkannda)
 {
 Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
 LoadString(Thread.CurrentThread.CurrentCulture);
 lkannda = false;
 }
 else
 {
 Thread.CurrentThread.CurrentCulture = new CultureInfo("kn-IN");
 LoadString(Thread.CurrentThread.CurrentCulture);
 lkannda = true;
 }
 }   
 }

and i created 2 resource files one for kannada and another for english with name Strings.kn-IN.resx and Strings.resx

Can any one tell me what is the error in this code. and how i can type kannada in textbox as image shows? and what else i need to add for this code?

For taking user input in kannada, you can create a custom Text box control as described here

also you can get rid of resource files by using google website Translator which translates your page on the fly. you just need to set you default language as Kannada

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM