I have a small site (8 or 10 pages) that needs to be translated into Spanish. I don't have access to a back end developer in order to use any sort of database or variables, and so I am going to try and finagle my way through this with just CSS/jQuery.
I know how to change the elements on a page from English to Spanish and vice versa. My problem is that once the visitor clicks to a new page, how I can make sure that the ne开发者_高级运维xt page displays in the proper language? Is this even possible?
The pages are .aspx but I don't have access to the code behind and I'm relatively useless in .NET. I wouldn't even take this on but its only a few pages with very little text.
Could someone help me get going in the right direction here?
It is possible to use cookie to save the chosen language.
I think that this will work:
function changeLang(lang) {
var a = 0;
Set_Cookie('lang',lang, 30, "/");
location.reload(false);
}
function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );
if ( expires )
{
expires = expires * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );
document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}
How about Sunday Morning--it's Google Translate done with Jquery. Simple, quick, and no DB required.
http://sundaymorning.jaysalvat.com/
you could do it with css only:
<div class="text-1"></div>
in your css file:
.text-1:after {
content: "Hello World"
}
now all you need is a css file for every language,
find demo here http://jsfiddle.net/CyfBF/1/
精彩评论