I found an easy way to use i18n with Templates. I think it’ not a REAL template system, but I got the job done. After the first config of my CodeIgniter setup I decided to implement a multilingual system. Following these steps I noticed that every translated page has it’s own view. This is not good, if my designer change one tag, one line, he would have to change every translated view.
The trick is simple, and I guess there is another elegant way to do this. The article I read said if I have a custom view called “myview”, I don’t need to rename this file to work with my default language, but my translated view must have a suffix, myview_pt.php for example. But in my case, even the default language must have the suffix, and the view without the suffix is my template.
The code bellow shows my custom controller, loading my view
[cc lang=”php”]
load_view(‘myview’); // Here I load my template that will be intercepted
}
}
/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */
[/cc]
My little modification begins here. I don’t need to call myview_pt from controller (checking what language first), because the modified controller from de article automaticaly does that. So, I simply create myview_en.php and myview_pt.php (assuming there is only those two languages), and the content of these files would be something like that:
[cc lang=”php”]
$this->lang->load(‘myview’, ‘english’); ?>
include('myview.php'); ?>
[/cc]
On the first line, “myview” is a language file located on system/language/english/myview_lang.php.
This way I can put my whole html/css stuff on myview.php and work simulating a template. I hope someone could say in the comments “here’s the better way to do this” but until there I’ll use this tricky code to get things working.
That’s all!
Thanks for the great tips.
Hmm. Good.
I came across. Thank you.
I recently discovered this blog. I’ve had a similiar idea to your rewriting the ten commandments for some time now.
Thanks for this – great idea.
Good post.
Thanks for your interesting article
Thanks for this – great idea.
Good blog
Thanks for your interesting article
Keep up the good work! 🙂
I really love to try it out. This is something new
I have a plan to change my sites to multilanguage. I hope it will help for my plan. Thank you for this post.
Give somebody the to a site about the, Discount keeley hazell sex tape [url=http://blog.bitcomet.com/post/304584/#1]Discount keeley hazell sex tape[/url], dxhw,
really great sites, thank you, noelia sex tape discount [url=http://blog.bitcomet.com/post/304596/#1]noelia sex tape discount[/url], 18409,
What is it, Best vanessa hudgens sex tape [url=http://www.vanessahudgenssextape.350.com/#1]Best vanessa hudgens sex tape[/url], %OO,
Only, vanessa hudgens sex tape discount [url=http://blog.bitcomet.com/post/304607/#1]vanessa hudgens sex tape discount[/url], %[[[,
Great site. Keep doing., kristin davis sex tape [url=http://blog.bitcomet.com/post/304632/#1]kristin davis sex tape[/url], 554629,