Welcome Guest, Not a member yet? Register   Sign In
CI 2.0 language helper is not working correctly
#1

[eluser]machureach[/eluser]
Can anyone help me?

I have a problem with:
$this->lang->load("menu", "english");

Above line print out like this:
$lang["menu_hom"] = "Home";
$lang["menu_set"] = "Setup";
$lang["menu_hel"] = "Help";

When I use below functions:
<?= lang("menu_hom"); ?>
or <?= $this->lang->line("menu_hom"); ?>
or <? echo lang("menu_hom"); ?>
or <? echo $this->lang->line("menu_hom"); ?>

Nothing print out.
#2

[eluser]InsiteFX[/eluser]
You also need to create the language file.
application/language/english/menu
Code:
$this->load->helper('language');

$this->lang->load('menu', 'english');

// Above line print out like this:
$lang['menu_hom'] = 'Home';
$lang['menu_set'] = 'Setup';
$lang['menu_hel'] = 'Help';

// When I use below functions:
<?php echo $this->lang->line('menu_hom');?>

InsiteFX
#3

[eluser]machureach[/eluser]
I mean when I use this [ $this->lang->load('menu', 'english'); ],
it prints out these:
$lang['menu_hom'] = 'Home';
$lang['menu_set'] = 'Setup';
$lang['menu_hel'] = 'Help';

it should keep it in memory not print to screen!
but when I use [ <?php echo $this->lang->line('menu_hom');?> ]
nothing print out.
#4

[eluser]InsiteFX[/eluser]
Then you need to show your language file and Controller code!

InsiteFX
#5

[eluser]bsauls[/eluser]
for one thing, you can't use short tags <?= in CI 2.
#6

[eluser]InsiteFX[/eluser]
@bsauls for one thing, you can’t use short tags <?= in CI 2.

And Why Not?

application/config/config.php
Code:
$config['rewrite_short_tags'] = TRUE;

Of course it depends on if it is turned on in php.ini.

InsiteFX
#7

[eluser]machureach[/eluser]
just today i test it again and i found that i forgot the php open tag "<?php" in the language files...
sorry for this and thanks for the reply




Theme © iAndrew 2016 - Forum software by © MyBB