Language change salution - NASTY

setekh

No avatar

2006-08-17 05:27

I browsed thru the forum, but still can not find a module for language change in run-time, and as the config for language is hardcoded in the general.php that is loaded every time, it's a pain in the ass to change the value and not have trouble later, so i just did something very nasty and fast but it actualy work.. a little script that just changes the general.php with one saved befoure for the language i want...
You make a general_en.php file and general_[YOUR_LANG].php ...
then add some buttons in page.tpl
<a href="./script_en.php"> <img border="0" src="en.gif"> </a>
...
The script itself is NASTY as i said :
copy this to script_en.php

// NASTY change language by MAXI - admin@bg0.org

// check the file and close the handle, just for safe reasons, you may add some error checking here..
$fileHand = fopen('.\config\general.php', 'r');
fclose($fileHand);
// Erase the OLD general.php file
$myFile = ".\config\general.php";
unlink($myFile);
// Copy the new file with the language options and other options as well
$source=".\config\general_en.php";
$dest=".\config\general.php";
if (!copy($source, $dest)) {
print ("failed to copy $dest...<br>\n");
}
// So now we have this :
// $config['language'] = "en";

// And reload the page
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;url=index.php\">";

Another file for another language and so on and on and on....

The other way is to change directly the value of $config['language']; but it's more dificult well more elegant as well but ... who cares as long as it works... CHMOD-ing your general.php file to 777 is not a good thing to do :) but still who cares :)

If you simply can not get it just mail me...

-=DMG=-

pvili

No avatar

2006-10-27 07:54

hi your are example?

Back to top
about us | contact