![]() |
Two languages at once - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Two languages at once (/showthread.php?tid=32630) |
Two languages at once - El Forum - 07-29-2010 [eluser]Loquela[/eluser] Hi there, I think this question is different from all the other language-reated questions... I'm currently working on a multilanguage website that displays all the content on a page in two languages simultaneously. Basically its a communication tool which allows pairs of users to select their respective languages and the text is displayed at once in both languages (language A and Language B). The content is a finite list of around 600 unique strings, mainly questions and responses. Is there a way to use the CI Language class to load TWO languages at once and display the text in both languages? We cannot make any assumptions about the language pair combinations, these would be completely random. cheers, L. Two languages at once - El Forum - 07-29-2010 [eluser]n0xie[/eluser] Would be easier to just store the 'translations' into a database with an ID for what language it belongs to. From there it's rather easy to display both languages at once. Two languages at once - El Forum - 07-29-2010 [eluser]Jelmer[/eluser] I took a quick look and I don't see any reason why one couldn't just instantiate a second instance of the language class and load the second language in there. Try something like this: Code: $this->lang_2 = new CI_Language(); Just remember that if you're using anything that automaticly displays a language line (like the lang() helper function) it'll only work for the first language. EDIT, Just a thought: a simpler but bit more messier way would be to use prefixes in you language keys so you can load them both into a single language class instance and use lines like this: Code: $this->lang->load('questions', 'english'); Code: $lang['en_question1'] = 'something'; Two languages at once - El Forum - 07-29-2010 [eluser]Loquela[/eluser] Thanks both, I think creating the additional language class instance was what I was looking for with my question (thanks Jelma). But I am also battling with the dilema of the database/resource file option. n0xie, would the database option be your recommendation? Cheers. Two languages at once - El Forum - 07-29-2010 [eluser]n0xie[/eluser] You could save the output of your database to a language file. It's basically up to you what you find is easier... |