CodeIgniter Forums
Codeigniter Multilanguage Question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Codeigniter Multilanguage Question (/showthread.php?tid=15333)



Codeigniter Multilanguage Question - El Forum - 02-01-2009

[eluser]JayArias[/eluser]
Hello , I am creating a cms that will present massive amounts of news to large Latino and American groups here in the united states and in other regions of the world. My question is; is there any way/plug ins/scripts that I can use to translate the data presented on the website?

eg:
Code:
<&lt;?=anchor(''.$SITE_URL.'/en', 'English');?&gt; |&lt;?=anchor(''.$SITE_URL.'/es', 'Enspanol');?&gt;



Codeigniter Multilanguage Question - El Forum - 02-01-2009

[eluser]Phil Sturgeon[/eluser]
The best way to do this is find some way of remembering what language to use, then set a constant with that language code very early on. Here you would take the last URI string (using array_pop() in a pre controller hook perhaps?) and set define('LANG_CODE', 'en') or whatever fr all of CI to see.

You cannot actually translate page content without hooking into google Translate or some other third-party lib, but you can easily have language specific content. By storing a language code in the database next to the content, you can say "SELECT * FROM news WHERE lang = 'en' or lang = ''" and you have your site accepting multi-lang.

If you need a little help with this here is a post with a few examples on how to do this.

How to make a multi country web site? (Best practices)