Archive for the ‘programming’ Category
Useful Language-Changing JavaScript
Written by Zealus on September 13, 2008 – 9:41 am -Recently I had to quickly make a copy of the same web site iin a different language. Instead of coming up with complicated solutions (the web site isn’t that big and the second language was long overdue) I decided to copy the contents into a subdirectory and just substitute the contents in English with the same in Spanish.
The thought behind was that I can alternate between each page using simple javascript routine. So there I have example.com in English, example.com/sp/ same thing in Spanish. Same pages are named the same, so it’s example.com/about_us.html and example.com/sp/about_us.html - otherwise the script it useless.
The function is fairly simple:
function langChange() {
var pt = location.pathname;
var hs = location.host;if (pt.length < 4) {
newloc = ‘http://’ + hs + ‘/sp/’;
} else {
if (pt.substring(0, 4) == ‘/sp/’) {
newloc = ‘http://’ + hs + ‘/’ + pt.substring(4);
} else {
newloc = ‘http://’ + hs + ‘/sp’ + pt;
}
}
window.location.assign(newloc);
}
Pretty universal, works everywhere. Set in as an onclick() event for your language changing butn and you’re good to go.
P.S. If you have much faith in Javascript - feel free to add ajax call to database for current page to figure out the counterpart in a different language.
Popularity: 17%
Tags: code, javascript, multilanguageYou might also be interested in reading this:
Tags: code, javascript, multilanguage
Posted in programming | No Comments »
Security threats
Written by Zealus on May 4, 2006 – 12:30 am -Somebody out there doesn’t really like Invision PowerBoard… today I saw fifth (yeah, that’s number 5) vulnerability patch for single release 2.1.5
People on IPS forums are screaming…
Popularity: 13%
Tags: programming, technology, webYou might also be interested in reading this:
Tags: programming, technology, web
Posted in programming, technology, web | Comments Off
Hosting, JavaScript, Chicago
Written by Zealus on December 22, 2004 – 4:32 am -First of all - I got rid of hoster that didn’t care to respond, clients found themselves a new home (I was loosing money on ASP hosting anyway) and everyone feels bad. Well, this is life, you get up and start all over again…
Great post on Blogspot by Chris Justus - he reverse-engineered Google’s JavaScript that takes care of Google Suggest… Very bright and interesting article…
Plans on the trip to Chicago are more real then I thought, hopefully I’ll fly there on a second week of January.
Popularity: 10%
Tags: programming, web, zealus.comYou might also be interested in reading this:
Tags: programming, web, zealus.com
Posted in programming, web, zealus.com | 1 Comment »
