Welcome Guest, Not a member yet? Register   Sign In
Model validation field translation
#1

(This post was last modified: 06-12-2020, 07:52 AM by snelledre.)

All,

Is it possible to translate the field in model validation?

In the controller it can with :

Translation of message and validation labels
To use translated strings from language files, we can simply use the dot syntax. Let’s say we have a file with translations located here: app/Languages/en/Rules.php. We can simply use the language lines defined in this file, like this:

Code:
$validation->setRules([
        'username' => [
            'label'  => 'Rules.username',
            'rules'  => 'required|is_unique[users.username]',
            'errors' => [
                'required' => 'Rules.username.required'
            ]
        ],
        'password' => [
            'label'  => 'Rules.password',
            'rules'  => 'required|min_length[10]',
            'errors' => [
                'min_length' => 'Rules.password.min_length'
            ]
        ]
    ]
);


But in the documentation is no example for model validation.

André
Reply
#2

Now i named the tables in the database in dutch, with this way i get the error messages all in dutch.
But it's cleaner to name the tables in english and translate them in codeigniter to the dutch languages.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB