Is my implementation of multi language okay? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Is my implementation of multi language okay? (/showthread.php?tid=66896) |
Is my implementation of multi language okay? - jethro - 12-15-2016 Hi guys, There are so many different ways to add multi-language functionality to a CI installation. I went ahead and put together something that looks like it will work and I would like some feedback. Background: My website purpose is to sell online English lessons to people in Europe. It is crucial that my site is multilingual. Caveat: I use HMVC modules to organize my site... as a result I am unable to implement /en/ or /fr/ urls. My website has four user areas:
Here is what I am doing: I am storing a users choice in a session variable "language". The default session language is set to English in the templates __constructor() like this: PHP Code: /** So when someone requests my home page I call the templates controller and the frontend method. PHP Code: /** So my language translations are of course in the Application->language folder... here is how I have it structured: Because there is actually quite a bit of language that needs to be translated (e.g. footer, form validation, actual content and paragraphs, menus, blurbs) I was thinking of splitting up the translations to different files such as frontend/footer_lang.php, frontend/header_lang.php etc... and then including them all into a master "frontend_lang.php"... is that a good idea? As for the actual implementation of the language switcher... I have a dropdown menu with my different language options: So when a user selects 'french' for example, they get redirected to base_url/language/switch_language/french controller that looks like this: PHP Code: class Language extends MX_Controller So basically I am just setting the user language session variable and redirecting to the last url page they were on. I am interested to hear some feedback on my solution. Many thanks. Jethro. |