codeigniter template engine including language parser

Viewed 1789

I don’t see any mechanism to refer to a language_key within a view that will be rewritten by the Template Parser. Right now, my view contains strings like:

{register}
{userid}
{password} 

I want these replaced by the matching strings from the Language definition, as if I had done this in the view:

   <?=$this->lang->line('register')?>
   <?=$this->lang->line('userid')?>
   <?=$this->lang->line('password')?> 

However, I don’t see any mechanism to support this automatically. So, I’m doing this in the controller:

$data = array(
'userid' => $this->lang->line('userid'),
'password' => $this->lang->line('password'),
'register' => $this->lang->line('register')
);
$this->parser->parse('register', $data); 

This seems rather silly to me. I think the Template Parser class should automatically support expansion of any defined language_keys. Perhaps by using a second set of delimiters:

[register]
[userid]
[password] 

Or maybe by using a certain indicator like an underscore:

{_register}
{_userid}
{_password} 

Or perhaps the GetText style:

_(register)
_(userid)
_(password) 

Can somebody please tell me if the functionality I’m looking for is actually available and I just missed it? Otherwise, do my suggestions seem reasonable, or is there perhaps an even better alternative idea?

1 Answers
Related