Hi, I have build my CMS admin panel with two languages, for example adding seperate content for english and arabic. for example in the table news ID Language News_Title News_Content status 1 ENGLISH Obama Wins asfdsfsdaf 1 2 Arabic News in arbic arabic in News 2 so i have data with two languages... Now i am very confused how to develop my cms regarding front end. Initially i thought to develop my cms with 2 subdirectories ENGLISH and ARABIC, but i saw little difficulties in that, when am changing i want to make changes in another directory also, and if the language extends for french etc..it will be too tedious to meaintain i think so. So I am looking for my seniors suggestion in this situation. I belive i wl get. Thanks
You have to plan your CMS before starting the coding Make sure you separate templates and language strings from the application logic, you can find a lot of online tutorials on how to create multilingual applications.
Hi, As you said i i develop, the problem i felt is, regarding the language english you know the direction ltr, and for arabic rtl.. How to handle this in a single template, OOPS? This cause my confusion? i hope your expericene will help me. Thanks
This is common when doing multilingualism. If I were you I'll do it that way: A language has: * Definitions: name, code, a charset, a direction and maybe a flag, * Language strings When you load current language file(s) you know everything about that language including the direction, let's say on a variable $lang['dir'] which is declared on one of the language files Now on your template you check this variable when needed, something like that: // Common CSS for both LTR and RTL echo '...style.css'; if($lang['dir'] === 'ltr'){ // CSS for LTR languages echo '...style_ltr.css'; } else{ // CSS for RTL languages echo '...style_rtl.css'; } PHP: or even like this: // Common CSS for both LTR and RTL echo '...style.css'; // Direction specific CSS echo '...style_'.$lang['dir'].'.css'; PHP:
Better yet, store all static text into a "language" system. Depending on a given preference variable or what have you, the user should be able to select their language. If the sites are exactly the same but in different languages, language files are the way to go. Let me explain. english.php <?php $lang = array( // These numbers should simply be "Text Codes" // Now you can use whatever system you like, // but I prefer to block things by site area // with lots of extra room; we'll give us a range of // 1000 for each area. 1000 => "This is our first area", 1001 => "This is still our first area, but simply text 2", 1002 => "First area is located in 1000's", // Area 2 2000 => "This is the second area", 2001 => "Please be aware that there are MANY different ways this can be done", 2002 => "I'm merely doing this on the spot, so it's \"quick\" without much", 2003 => "thought put into the design; but hey! it'll work!" ); ?> PHP: arabic.php <?php $lang = array( // Change this content to arabic! // These numbers should simply be "Text Codes" // Now you can use whatever system you like, // but I prefer to block things by site area // with lots of extra room; we'll give us a range of // 1000 for each area. 1000 => "This is our first area", 1001 => "This is still our first area, but simply text 2", 1002 => "First area is located in 1000's", // Area 2 2000 => "This is the second area", 2001 => "Please be aware that there are MANY different ways this can be done", 2002 => "I'm merely doing this on the spot, so it's \"quick\" without much", 2003 => "thought put into the design; but hey! it'll work!" ); ?> PHP: page.php <?php // Switch this based of preference var // In our case right now we'll use ?lang=arabic // but default to english if($_GET['lang'] == "arabic"){ require_once("arabic.php"); } else { require_once("english.php"); } print "<table style=\"margin:auto;\"><tr><td>".$lang[1000]."</td><td>".$lang[1001]."</td></tr>". "<tr><td>".$lang[1002]."</td><td></td></tr></table>". "<table><tr><td>".$lang[2000]."</td><td>".$lang[2001]."</td></tr><td>".$lang[2002]."</td>". "<td>".$lang[2003]."</td></tr></table>"; ?> PHP: Now mind you, have not tested these merely just wrote them right now as examples, but they should work fine. Your language content will change based off the defined parameter. Regards, Dennis M.