phpmady Posted April 26, 2010 Share Posted April 26, 2010 hi, I want to develop website in 2 langauges arabci and english... already i have a website in english, that constitute folders like images js css templates home.php news.php articles.php ... .... now how to proceed for arabic language, is it better to make the entire website duplicated for arabic, or only the templates change is enough,,, like templates_arabic templates_english images js css home.php news.php articles.php ... .... Pls give me a suggestion, so that i can develop my website Thank You Link to comment https://forums.phpfreaks.com/topic/199784-website-in-2-languages/ Share on other sites More sharing options...
de.monkeyz Posted April 26, 2010 Share Posted April 26, 2010 The easiest way would be to use different template files as you suggested. A more complicated way, but doesn't repeat as much code is to have a language method when you output. So for example if you have this in a page <h1>News</h1> You would instead have <h1><?php echo lang('News'); ?></h1> And that method would check what language to use, and return the correct word. As to how you would get the correct word is up to you, you could use a flat file like a .txt file, or make a database table of terms with their translations. Link to comment https://forums.phpfreaks.com/topic/199784-website-in-2-languages/#findComment-1048625 Share on other sites More sharing options...
phpmady Posted April 26, 2010 Author Share Posted April 26, 2010 The easiest way would be to use different template files as you suggested. A more complicated way, but doesn't repeat as much code is to have a language method when you output. So for example if you have this in a page <h1>News</h1> You would instead have <h1><?php echo lang('News'); ?></h1> And that method would check what language to use, and return the correct word. As to how you would get the correct word is up to you, you could use a flat file like a .txt file, or make a database table of terms with their translations. How can i traverse from one language to another language.. suppose if i am in news.php, i want to go to same in arabic news.php... Link to comment https://forums.phpfreaks.com/topic/199784-website-in-2-languages/#findComment-1048662 Share on other sites More sharing options...
de.monkeyz Posted April 26, 2010 Share Posted April 26, 2010 You can use a cookie or session to track their current language, or even a $_GET variable. For instance, if we went the get route and your pages could have links to http://www.mysite.com/?lang=arab You could have this line of code on every php file $language = isset($_GET['lang']) && $_GET['lang'] == 'arab' ? 'arab' : 'eng'; //Set language to arab if set in the url, otherwise default to eng. Then when you include you can do if($language == 'arab') include '/path/to/file/news_arab.php'; else include '/path/to/file/news.php'; Link to comment https://forums.phpfreaks.com/topic/199784-website-in-2-languages/#findComment-1048671 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.