How can I insert variables into translated sentences?

#1
[eluser]suntrop[/eluser]
I've got a multi-lang website and using the language class. But how do put variables in the translated sentences?

For example:
I want "You need 25 extra points.".

Is there something possible like ...
$lang['ui_messages'] = "You need $num extra points.";

#2
[eluser]tomcode[/eluser]
Code:
$lang['ui_messages'] = "You need %s extra points.";

$points = 25;
$fmt = $this->lang->line('ui_messages');

$ui_messages = sprintf($fmt, $points);

#3
[eluser]JuanG[/eluser]
Hi, I was asking myself the same question but regarding to anchors.

Before adding internationalization to my web I had the following string:

Code:
"...is called <strong>&lt;?php echo anchor('www.cnn.com', 'CNN'); ?&gt;</strong>.  It's a..."

Now it won't work when included into:

Code:
$lang['home_dilemma_intro'] = "...is called <strong>&lt;?php echo anchor('www.cnn.com', 'CNN'); ?&gt;</strong>.  It's a...";

How can I keep my anchors when translating the text?

Thanks in advanced,

#4
[eluser]Kristories[/eluser]
Try this..
Code:
$lang['home_dilemma_intro'] = "...is called <strong>".anchor('www.cnn.com', 'CNN')."</strong>.  It's a...";

#5
[eluser]JuanG[/eluser]
That worked out.

Thanks!

#6
[eluser]Kristories[/eluser]
Wink


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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