I am very much thankful to you for your previous help and support. This time again I need your support n help. I have a website with source code in asp.net. Now I have to give option in my master page for selecting different languages and can be seen globally
as per the users desired language. Kindly help me, I will be really very much thankful to all of you.
Microsoft JScript runtime error: 'content' is undefined..this is the error when i choose languages from the dropdown list. Kindly see the below code of my page.
<%@ Master Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<script type="text/javascript"
src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
// Initialize version 1.0 of Google AJAX API
google.load("language", "1");
function translate(lang) {
var source = document.getElementById("article").innerHTML;
var len = content.length;
// Google Language API accepts 500 characters per request
sufyansaeed
Member
15 Points
13 Posts
Website in different language
Jan 13, 2012 10:55 AM|LINK
Dear Friends,
I am very much thankful to you for your previous help and support. This time again I need your support n help. I have a website with source code in asp.net. Now I have to give option in my master page for selecting different languages and can be seen globally as per the users desired language. Kindly help me, I will be really very much thankful to all of you.
Please please treat this urgently.
Thanks in advance.
Regards
Sufyan.
kedarrkulkar...
All-Star
34013 Points
5468 Posts
Re: Website in different language
Jan 13, 2012 12:32 PM|LINK
there are two options to do it...
use google transation to automatically convert web site content while displaying...
http://forums.asp.net/t/1589483.aspx
but since u dont have control over that translation (and if u require that) u can go for globalization feature of asp.net
http://www.codeproject.com/KB/aspnet/localizationByVivekTakur.aspx
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/localization/localization.aspx#simpleexample
or simple google search on globalization/locallization would give u plenty of resources...
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site
Horizon_Net
Star
8277 Points
1435 Posts
Re: Website in different language
Jan 13, 2012 12:59 PM|LINK
Hi,
like said above globalization should be the way to go. You should start your research from here.
If my post solves your problem, please mark as answer.
sufyansaeed
Member
15 Points
13 Posts
Re: Website in different language
Jan 13, 2012 01:44 PM|LINK
Dear Kulkarni,
Microsoft JScript runtime error: 'content' is undefined..this is the error when i choose languages from the dropdown list. Kindly see the below code of my page.
<%@ Master Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<script type="text/javascript"
src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
// Initialize version 1.0 of Google AJAX API
google.load("language", "1");
function translate(lang) {
var source = document.getElementById("article").innerHTML;
var len = content.length;
// Google Language API accepts 500 characters per request
var words = 500;
// This is for English pages, you can change the
// sourcelang variable for other languages
var sourcelang = "en";
document.getElementById("translation").innerHTML = "";
for (i = 0; i <= (len / words); i++) {
google.language.translate(source.substr(i * words, words),
"en", lang, function (result) {
if (!result.error) {
document.getElementById("translation").innerHTML
= document.getElementById("translation").innerHTML
+ result.translation;
}
});
}
// Hide the text written in the original language
document.getElementById("article").style.display = 'none';
return false;
}
// Switch to the original language
function original() {
document.getElementById("translation").style.display = 'none';
document.getElementById("article").style.display = 'block';
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="translation"></div>
<div id="article">
<h1>
This is heading ...
</h1>
<p>
This is body part which is in paragraph tag.
</p>
<a href="#" onclick="original();">Switch to English</a>
<select onchange="translate(this.options[this.selectedIndex].value);">
<option value="de">deutsch</option>
<option value="pt">português</option>
<option value="fr">français</option>
<option value="ja">日本語</option>
<option value="ar">عَرَبيْ</option>
<option value="it">italiano</option>
<option value="ru">pусский</option>
<option value="po">polski</option>
<option value="zh-CN">中文</option>
<option value="es">español</option>
<option value="ko">한국어</option>
<option value="nl">nederlands</option>
<option value="hi">हिन्दी </option>
<option value="el">Ελληνική</option>
<option value="ro">română</option>
</select>
</div>
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
Thanks for your prompt reply....
Regards
Sufyan