In this year i wrote a very big website, with no CMS. I wrote it from scratch. Today i'm starting to implement a translation system.
The idea is, basically, to add /language/
inside the URL. This means if the index page, when i'm browsing on default language, has the url
http://www.racebooking.net/index.php
once the user clicks on the english flag in order to view the english version of the website, the URL will become
http://www.racebooking.net/en/index.php
in .htaccess, then, i have a rule which converts /en/
into ?lang=en
.
The problem
Every page has tons of links, which means i have thousands of <a href=".."></a>
tags in my website.
For example, on my index.php page, i have a link like this one
<a href="http://www.racebooking.net/forum">Forum</a>
which, if i am currently browsing the english version, should point to
http://www.racebooking.net/en/forum
At first sight, the idea was to change it to
<a href="http://www.racebooking.net/<?php echo $_GET['lang'] . '/';?>forum">Forum</a>
which works pretty good! But, the problem is i have thousands of <a>
tags on my website!!! it would be totally insane to change them all, for just adding <?php echo $_GET['lang'] . '/';?>
in them!! It would take days and days and days of work.
So, is there a smart way to add /language/
to all my website URLS?
EDIT
I would prefer not using any js. All the users with js disabled will encounter problems while browsing my website!