Welcome Guest, Not a member yet? Register   Sign In
extend library, extend language file?
#1

[eluser]jbowman[/eluser]
OK, we have ways of extending the default CI libraries, a popular one being the validation library. How do I extend the language file for it?

I don't want to mess with the system files, those will get updated when I upgrade CI. So I created a new validation_lang.php in application/language/english and added my strings for my custom extensions there. They worked, the default CI ones didn't

As a quick fix, I just copied the content of the CI language file into my own, but I was wondering if there was a better solution?
#2

[eluser]Unknown[/eluser]
Here's what I did:
Code:
<?php

include (BASEPATH.'/language/english/form_validation_lang.php');

$lang['regex_fixed']  = "The %s field is not in the correct format.";

// EOF
#3

[eluser]PhilTem[/eluser]
Since you're extending the Form_validation-library you can just load your language file in the __construct method like so

Code:
class MY_Form_validation extends CI_Form_validation {
  
  public function __construct()
  {
    parent::__construct();
    $this->CI->lang->load('MY_form_validation');
  }
}

and, just to be consistent, name your "extended" form_validation language file MY_form_validation_lang and store it in
APPPATH . 'language/english/MY_form_validation_lang.php
or whatever language you're wanting to extend.




Theme © iAndrew 2016 - Forum software by © MyBB