Support the ongoing development of Laravel.io →
Views Validation Architecture
Last updated 2 years ago.
0

You will probably change the language config when you change languages in the app. In that case you will need another dir on app/lang for the other language. You can just copy+paste the "en" dir and translate the messages or just simply, download the language you need from here: https://github.com/caouecs/Laravel4-lang

Last updated 2 years ago.
0

@herko

There is a setAttributeNames method in Validator. Simple usage:

$validator = Validator::make(Input::all(), $rules);
$validator->setAttributeNames(array(
    'name' => 'Category',
));

Create a new file as app/lang/en/attributes.php. For example

return array(

	'category' => array(
        'name' => 'Category',
        'type' => 'Type'
	),
	'product' => array(
        'name' => 'Product',
        'quantity' => 'Quantity'
	)

);

create a copy of it for every language and edit contents:

app/lang/fr/attributes.php, app/lang/de/attributes.php ...

and use it with your validator:


// Category validator
// If app locale is fr, it will look for app/lang/fr/attributes.php
$validator->setAttributeNames(Lang::get('attributes.category'));

// Product validator
$validator->setAttributeNames(Lang::get('attributes.product'));
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

herko herko Joined 13 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.