• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mod to have language keys automatically recognized by the template parser

#1
[eluser]Yoglets[/eluser]
This post is my solution to the question I posed here: http://ellislab.com/forums/viewthread/56508/

I made a very simple mod to Parser.php:
Code:
--- Parser.php.orig     2007-07-16 17:22:46.000000000 -0500
+++ Parser.php  2007-07-16 17:23:14.000000000 -0500
@@ -47,6 +47,11 @@
                $CI =& get_instance();
                $template = $CI->load->view($template, $data, TRUE);

+               foreach ($CI->lang->language as $key => $val)
+               {
+                       $data['_(' . $key . ')'] = $val;
+               }
+
                if ($template == '')
                {
                        return FALSE;
This simply adds a special coded entry to the existing $data array for each entry in the language array. Thus, instead of having to use a template with this:
Code:
<?=$this->lang->line('string')?>
Or having to explicitly map this value to your $data array in your controller like this:
Code:
$data['string'] = $this->lang->line('string');
One can simply use this in the template:
Code:
{_(string)}


Messages In This Thread
Mod to have language keys automatically recognized by the template parser - by El Forum - 07-16-2007, 04:33 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.