Having problem with my language file |
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.
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
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!';
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!
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!
You need to do the same for %d that you did for %s
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
'%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!'; |
Welcome Guest, Not a member yet? Register Sign In |