PHP multilanguage directory

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
salman1karim
Forum Newbie
Posts: 4
Joined: Mon Oct 03, 2011 7:51 am

PHP multilanguage directory

Post 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?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHP multilanguage directory

Post 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.
salman1karim
Forum Newbie
Posts: 4
Joined: Mon Oct 03, 2011 7:51 am

Re: PHP multilanguage directory

Post 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.
salman1karim
Forum Newbie
Posts: 4
Joined: Mon Oct 03, 2011 7:51 am

Re: PHP multilanguage directory

Post 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>';
Post Reply