• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Remove Codeigniter <label> wrapping lang()

#1
[eluser]John-Doe[/eluser]
Hello,

How do I remove the auto label wrapping that is for the lang() in Codeigniter.

The manual doesn't say anything about it: http://ellislab.com/codeigniter /user-guide/helpers/language_helper.html

Do I have to write a function by myself or is there a simple clean way that Im missing?

/John-Doe

#2
[eluser]Tpojka[/eluser]
Read here.

#3
[eluser]John-Doe[/eluser]
Im using lang(); because I want to send a dynamic value with it, like lang('welcom_user', $username); . $this->lang->line(); doesn't support this, so its not an option.

#4
[eluser]Tpojka[/eluser]
Just write:
Code:
Welcome, &lt;?php echo isset(lang('username')) ? lang('username') : 'Guest';?&gt;

#5
[eluser]John-Doe[/eluser]
[quote author="Tpojka" date="1383339827"]Just write:
Code:
Welcome, &lt;?php echo isset(lang('username')) ? lang('username') : 'Guest';?&gt;
[/quote]

But that won't work either.

Of course I want to be able to translate "Welcome" beofre the message as well.

Code:
lang(‘welcom_user’, $username);

Variable in lang file:
Eng-ver: Welcome %s to this page
Swe-ver: Välkommen %s till denna sidan

With your code I won't be able to translate the whole variable.

#6
[eluser]Tpojka[/eluser]
Use placeholders in language files.

Code:
//In your language file...
$lang['welcome_username'] = 'Welcome %s.';

//then in your view or controller..
echo ( sprintf( lang("welcome_username"), "Bob") );
//Results in   "Welcome Bob."


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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