Hi i am working on a running site which is in english language on codignator plateform but i have to convert it into arabic also, but i have less time to do it , i have not much time to crate a language file of all the static english text to arabic translation and not allowed to use google translate plugin.so if any body have any idea then please share with us Thanks
If you think your visitors will be attracted by that robotic translation from google you're all wrong. You can easily go and create a simple structure like this: dir -> lang/ dirfile -> en.ini (english language file) dirfile -> de.ini (deutsch language file) dirfile -> etc (and so on, for whatever languages you want) Code (markup): Anyway, the structure is easy to create on an ini file if you've ever seen one before so, do the same structure for every file, en.ini (in-file structure) [index]login = "Log in" register = "Register an account" forgot_password = "Password forgotten" [dashboard] logout = "Log out" messages = "Inbox" settings = "Settings Code (markup): Same structure applies to de.ini for example, only the quoted string changes. Now, we need a global function for example (if you have any knowledge about CodeIgniter you can simply create a Language controller, but, lets stick to the global function for the time being. Just open the index.php file and before the $app->run(); or whatever type of controller you're having to run your application just create a function like this above: // defining the function function lang($lang) { // setting the default to english, in case there's a mismatch $lang = (in_array($lang,array('en','de')) ? $lang : 'en'; return parse_ini_file('lang/'.$lang.'.ini',true); } // pulling the language data $lang = lang($_COOKIE['language']); PHP: Now, all thats left to do is to change how language strings are printed, so, go to application/views and change every static language string with, for example: //index.php (view file) //[...] random html code <button id="login-button">Log in</button> // this row needs to be changed like this <button id="login-button"><?=$lang['index']['login'];?> //[...] random html code PHP: It depends on your PHP version, greather thnn 5.4.x versions of PHP are not allowing short-tags anymore so you will need: <?php echo $lang['index']['login']; ?> Code (markup): Just in case you are looking for a controller, it's even easier: class Language { function __construct() { $lang = (in_array($_COOKIE['language'],array('en','de')) ? $_COOKIE['language'] : 'en'; $this->lang = parse_ini_file('lang/'.$lang.'.ini',true); } public $lang; public function get($section,$block) { return ($this[$section][$block]) ? $this[$section][$block] : $section.'['.$block']'; } } PHP: Then all you need to do is instantiate a $lang variable like this: $lang = new Language(); // then simply use it like this echo $lang->get('index','login'); PHP: It's a general idea, thinking you're saving the language in a cookie instead a DB, whatever, you can use this however you want. Hope it helped, regards.
But sir i want to know that is this process translate all the static text of site into arabic without crating __lang.php file in language folder according to me i was trying to crate another application folder in root directory of codignator and have copy complete application folder into arabic application folder and try to create link like www.example.com for English site and www.example.com/arabic for Arabic sit and follow the instruction given on this link http://sumonbd.wordpress.com/2009/09/16/develop-multilingual-site-using-codeigniter-i18n-library/ without crated separate language file but its not working and of-course i have make change in index.php to create two separate application in codignator so i nead help Thanks