CodeIgniter Forums
Variables in Language files !! - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Variables in Language files !! (/showthread.php?tid=17843)



Variables in Language files !! - El Forum - 04-17-2009

[eluser]Mahmoud M. Abdel-Fattah[/eluser]
I'm creating a multi-language website. I'm sending some mails to the users, and of course using variables in the mail, such as ( username, code, etc. ).

now can I use define the whole mail including Variables in the language file ??

or should I make it manually, in the email library file ?? for example :

Quote:if($this->session->userdata('language') == "eng")
$msg = "hello " . $username;
elseif
$msg = "مرحبا " . $username;

then the website admin will edit the language files & the mail library file too !


Variables in Language files !! - El Forum - 04-17-2009

[eluser]Armchair Samurai[/eluser]
Take a look at printf() and sprintf() - you can echo out the result in your view.
Code:
// in your language file
$lang['greeting'] = 'Hello %s';

// in your view
<?php printf(lang('greeting'), $username);?>



Variables in Language files !! - El Forum - 05-15-2009

[eluser]RJ[/eluser]
Perfect, just what i needed, thanks @Armchair Samurai