Support the ongoing development of Laravel.io →
Validation Laravel

In my case,Many tables has the column called name.In English,This word can use in everywhere,In different scene it represents different meanings. But in Chinese,This word can be translated to many different word like 名字 which means personal name,名称 which means item name and so on.

This is a simple example,In the lang files,I can only defined an array,'attributes'=>['name'=>'名字']

I have an idea and Laravel did not implement this feature,Like this:

'attributes'=>['table_name.column_name'=>'名字'].

Any suggestions?

Last updated 3 years ago.
0

Don't you have lang files for each model?

0

Validation just use one lang file

0

So you'll have to use either of the following:

  1. If you're doing validations in the controller, i.e. $this->validate($request, [...]) you can use the custom error messages
  2. If you're using form requests, you have the attributes() function to help you
  3. If the app is still in dev, you can rename the fields so the English will corresponde the Chinese word
0

Actually I'm using Laravel Nova and It's not provide a method to define custom error messages or custom attributes. So I have try to find another way.

Looks like is Nova's issue.

By the way,I think the good way to resolve this issue is handle it in Lang files.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

ice winter-ice Joined 28 Aug 2019

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.

© 2025 Laravel.io - All rights reserved.