CodeIgniter Forums
CI language handling - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: Best Practices (https://forum.codeigniter.com/forum-12.html)
+--- Thread: CI language handling (/thread-77.html)



CI language handling - discofunk - 11-02-2014

Hi

I am a noob to CI and php generally. I am however writing a website that will have content that mostly should stay the same that needs to be in different languages.

I am confused what the best practice for this is…

1. Should I have the content of each page in language text files and use the CI language function? OR
2. Should I have the content in a database with different columns/fields for the different languages? OR
3. Should i have the content in different databases for each language?

It must be something that a million people have had to do but I’m not sure what is the best way…also what happens with things like headers and footers, etc??

Many thanks for anyone taking the time to help

Tom


RE: CI language handling - ivantcholakov - 11-02-2014

1. You need language files for each language. The language strings translate the user interface mainly. Except your custom language file(s) you need to have translations the CodeIgniter language files.

2., 3. About the database structure: This link explains and compares possible approaches http://www.apphp.com/tutorials/index.php?page=multilanguage-database-design-in-mysql . I personally like "4. Additional Translation Table Approach".

Also you have to think about data entry for the different languages, if you have an administration panel, you would need sort of multi-language CRUD. And if you store site settings within the database, you would have to find a way how it would be done for language-sensitive ones.

All these things are challenging and time consuming, not for "noobs". On the other hand, you wrote that your site would be simple. I would like to propose you first to have a look at CMS that supports multiple languages - http://ionizecms.com/ (it still uses CodeIgniter 2), and then to decide whether to code from scratch or to find/use a ready yet solution.


RE: CI language handling - Hobbes - 11-02-2014

well on a quick google search i found this, a couple years old now but it should still work :

https://code.google.com/p/gtranslate-api-php/


RE: CI language handling - ivantcholakov - 11-02-2014

@Hobbes

It is not about translation by human beings. :-) For specific purposes this "GTranslate" could be used, be aware however about the restrictions of GNU GPL v3 license.