如何在我们的网页上添加区域语言?

时间:2013-10-19 07:46:21

标签: c# asp.net css

我审核了This Link 1how to use kannada font in asp.net? 但我无法在我的页面中使用卡纳达语。我想在文本框中键入卡纳达语。 Kannada text Box 但它没有发生......任何人都可以告诉我这可能是什么原因?

我的源代码在这里: forKannada.css文件

  @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文件

 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;
 }
 }   
 }

我创建了2个资源文件,一个用于kannada,另一个用于英文,名称为Strings.kn-IN.resx和Strings.resx

任何人都可以告诉我这段代码中的错误是什么。以及如何在图像显示中在文本框中键入kannada?还有什么我需要为此代码添加?

1 个答案:

答案 0 :(得分:2)

要在kannada中获取用户输入,您可以按照here所述创建自定义文本框控件

您也可以使用google website Translator来动态删除资源文件。你只需要将默认语言设置为卡纳达语