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
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'));
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community