Welcome Guest, Not a member yet? Register   Sign In
How to organize views for different languages
#2

[eluser]CroNiX[/eluser]
Either would work and I guess it comes down to preference. No it wouldn't be a problem to have the same file name in different folders.

Code:
$lang = 'es'; //I imagine you have a similar variable defined somewhere
$this->load->view($lang .'/my_view');//load the view for this controller from it's language dir

or
Code:
$lang = 'es_';
$this->load->view($lang . 'my_view');

If every single page on your whole site will have this language convention, it might be better to extend the Loader class (MY_Loader) and override the view method with your own to automatically append your language to the beginning of the filename (or directory) so you don't have to manually set it everywhere. Or create an additional method specifically for loading language views so you can still use the original, if needed.

I'd probably DEFINE the language somewhere. Then in the loader, check to see if it's defined. If not, you can use some default language. If it is it will just use it.


Messages In This Thread
How to organize views for different languages - by El Forum - 11-20-2013, 09:29 AM
How to organize views for different languages - by El Forum - 11-20-2013, 01:09 PM
How to organize views for different languages - by El Forum - 11-20-2013, 01:31 PM
How to organize views for different languages - by El Forum - 11-20-2013, 01:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB