Page 1 of 1
PHP multilanguage directory
Posted: Thu Jun 26, 2014 1:48 am
by salman1karim
Hi,
My Website directory structure
ABC
|_includes, documents,images,AR,index.php
|_top_menu.php, side_menu.php
under the ABC folder is sub folder with the main index.php. The AR (Arabic language folder) is under the same directory structure folder is like ABC but with Arabic content. In both directory have more than 20 folders with sub folders.
In top_menu.php and side_menu.php define the menu contents.
My question is that how can i use switch language folder without changing the directory structure?
Re: PHP multilanguage directory
Posted: Thu Jun 26, 2014 1:04 pm
by requinix
You don't have any switching already in place?
With simpler solutions like this, often there's some sort of URL rewriting or virtualhost-based scheme to switch the "document root" to the desired location. Like if you used a subdomain, ar.example.com, you'd have a virtualhost pointing it to /ABC/AR. If you had a subdirectory in the URL, like
www.example.com/ar, then it'd likely be URL rewriting to point all files towards /ABC/AR/* instead of the /ABC/* they originally were going to be.
Re: PHP multilanguage directory
Posted: Tue Jul 01, 2014 3:14 am
by salman1karim
I didnt use switching?
I have same directory structure for English and Arabic content. But i don't know how can i use URL switcher between two languages.
Re: PHP multilanguage directory
Posted: Tue Jul 01, 2014 7:39 am
by salman1karim
At last i resolve issue my self. May be this is helpful for anyone. If anyone want to use this code the directory structure should be same.
Code: Select all
<?php
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
$parse = parse_url($pageURL);
$a=$parse['host'];
$c=basename($_SERVER['PHP_SELF']);
$b='http://' . $a . '/abc/ar/' . $c ;
?>
Now Just give the link
Code: Select all
echo '<a href="' . $b . '"><img src="http://abc/images/icon.png" style="float:right; padding-right:5px; border:0;" /></a>';