![]() |
Having problem with my language file - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Having problem with my language file (/showthread.php?tid=64364) |
Having problem with my language file - wolfgang1983 - 02-13-2016 I am trying to set my error messages I have a small problem. On my library function set_error when I var dump my messages it says Code: file_extension_not_allowed_jpg Library Function PHP Code: public function set_error($message) { What I am trying to do when a message has _jpg Then some how make the Lang line pick it up uisng something like %s Code: $lang['file_extension_not_allowed_' . '%s'] = 'Your %s files is not allowed!'; So will save me having to create a new lang line in my language file. How my message is set PHP Code: public function multi_upload($field = 'userfile') { Any suggestion please if you have examples please show me. RE: Having problem with my language file - Diederik - 02-13-2016 The %s replacement you want to use is part of the sprintf PHP function. You could do something like this in your controller: PHP Code: public function multi_upload($field = 'userfile') { And in your language file: PHP Code: $lang['file_extension_not_allowed'] = 'Your %s file is not allowed!'; RE: Having problem with my language file - wolfgang1983 - 02-13-2016 Thank you for that. I tried it it now picks up %s fine but when I need to use %d first it does not work. It with %d it should be replaced with the file name the %s replaces correct but not the %d PHP Code: <?php PHP Code: public function set_error($message) { Out puts code below but when I echo $this->file_name for testing displays name. PHP Code: Your file 0 with the extension png is not allowed! RE: Having problem with my language file - InsiteFX - 02-13-2016 You need to do the same for %d that you did for %s RE: Having problem with my language file - Diederik - 02-13-2016 '%s' means a string format, a '%d' can only replace a digit. In your case you want to replace 2 strings so you should use 2 '%s' signs. PHP Code: $lang['file_extension_not_allowed'] = 'Your file %s with the extension %s is not allowed!'; |