![]() |
Language Parser Helper - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Language Parser Helper (/showthread.php?tid=7414) |
Language Parser Helper - El Forum - 04-08-2008 [eluser]wiredesignz[/eluser] I originally developed this helper class to allow functions to be parsed in views, but in a fit of brilliance I realise it could also solve a lot of issues for people using languages in their views. Please note this is completely untested, but may be beneficial to someone. Please try it and modify it as needed, your interest could benefit the CI community. Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); Language Parser Helper - El Forum - 04-08-2008 [eluser]wiredesignz[/eluser] On a second look much of the code wasn't needed. Should work a bit faster now. Please post your comments, Thanks for your interest as always. Language Parser Helper - El Forum - 04-08-2008 [eluser]Tom Glover[/eluser] Looks good ![]() Language Parser Helper - El Forum - 04-08-2008 [eluser]wiredesignz[/eluser] It may be of use to pass in the language name to parse with and have the helper load that language file. Code: class Language EDIT Update #1 = add language name to load Language Parser Helper - El Forum - 04-08-2008 [eluser]Tom Glover[/eluser] Nice Update, it does now work 1.5x times faster on my LAMP server, very use full indeed. Language Parser Helper - El Forum - 04-08-2008 [eluser]xwero[/eluser] If i understand it correct you can code something like Code: // template.php Language Parser Helper - El Forum - 04-08-2008 [eluser]wiredesignz[/eluser] Yes, except I used {?pagetitle}, but really after looking at your code, the ? is not even needed. Thanks xwero ![]() Update #2 = remove ? Of course the view can be echo'd or appended to $this->output as required Language Parser Helper - El Forum - 04-08-2008 [eluser]xwero[/eluser] I find it strange you don't have to add files to the load->language method Code: function language($file = array(), $lang = '') Language Parser Helper - El Forum - 04-08-2008 [eluser]wiredesignz[/eluser] What is strange about it xwero? If $file is not an array it is converted to an array Language Parser Helper - El Forum - 04-08-2008 [eluser]xwero[/eluser] As you can see the method makes use of the lang->load method which is the method that gets the language file which provides the line but because there is not file it should throw an error or you should have a /language/english/english.php file. The language is the second parameter. |