Welcome Guest, Not a member yet? Register   Sign In
Help extends CI_Lang
#1

[eluser]mikelin[/eluser]

Greetings to all
I'm new to this forum and recently I met Codeignerit and I'm building my first app.
I used the class Lang and I noticed
echo ($ this-> lang-> line ('key_label'));
and if key_label exists return its translation otherwise not echo

how can I modify the class Lang for if exists return translation, if not exists return key_label
Can you help me .. ?
.. for me this is the first modification of a class

Thanks again and bye--
#2

[eluser]XMadMax[/eluser]
Hey mikelin, you must to use lang('My String'); from the language helper, instead of ussing $this->lang->line.


#3

[eluser]mikelin[/eluser]
Tk For Help ....

if i use
echo lang('My_String')
where 'My_String' is not define

not return My_String ?
TK
#4

[eluser]XMadMax[/eluser]
Yep, you must to write your own MY_language_helper.php:

Code:
if ( ! function_exists('lang'))
{
function lang($line, $id = '')
{
  $CI =& get_instance();
  $newline = $CI->lang->line($line);
  if ($newline == FALSE) $newline=$line;

  if ($id != '')
  {
   $newline = '<label for="'.$id.'">'.$newline."</label>";
  }

  return $newline;
}
}
#5

[eluser]mikelin[/eluser]
thanks it works .. but to be honest I still can not understand because work ..
Tk
#6

[eluser]XMadMax[/eluser]
Simple, $this->lang->line('something') returns FALSE when not found, the whe lang function test it in if ($newline == FALSE) $newline=$line; restoring original value to be returned.





Theme © iAndrew 2016 - Forum software by © MyBB