Comments (5)
The issue is with the method getAttributeFromTranslations in Illuminate\Validation\Concerns\FormatsMessages. It expects trans('validation.attributes') to be an array, but because our translator flattens the content of the validation file, validation.attributes is just empty in our case.
@jeremyargoud's solution works because it goes from dot notation to multi-dimensional array when loading from the Database.
Version 2.2.1 fixes this issue.
from translation.
Because of how the validator works, I believe the attributes do not work.
from translation.
how repair it?
from translation.
you can try something like this:
'custom' => [
'nick' => [
'required' => 'You must choose a nickname.',
],
that will work. Trying to set attributes did not work for me either so I tried custom and it worked.
from translation.
Hello,
To solve the problem, I had to use array_set helper in loaders.
In waavi\translation\src\Loaders\FileLoader.php:
public function loadSource($locale, $group, $namespace = '*')
{
$result = [];
foreach (array_dot($this->laravelFileLoader->load($locale, $group, $namespace)) as $key => $value) {
array_set($result, $key, $value);
}
return $result;
}
In waavi\translation\src\Loaders\DatabaseLoader.php:
public function loadSource($locale, $group, $namespace = null)
{
$result = [];
foreach ($this->translationRepository->loadSource($locale, $namespace, $group) as $key => $value) {
array_set($result, $key, $value);
}
return $result;
}
Now attributes are correctly translated for me :-)
from translation.
Related Issues (20)
- typo in readme
- Database schema: Connection
- After integration -> Unittest fails: Foreign Constraint HOT 3
- Mysql syntax error during migration. code: 1059 HOT 1
- Support for Laravel 6.0 HOT 1
- Change database structure to allow extra unique index HOT 1
- Set different tables names HOT 1
- Overriding current locale to fetch localized model attributes in specific language HOT 1
- Setting non-translatable raw attributes breaks translation
- translator:load throws db integrity error HOT 1
- Where do I find example codes ?
- How can I delete a language ?
- Browser's Locale: add Region
- Support for Laravel 7.0 ? HOT 3
- method isLocked() doesnot exit when use update translation
- array_replace_recursive(): Argument #1 is not an array HOT 5
- Migrations not publishing
- Support for Laravel 8.0? HOT 5
- not supported with url
- anyone continued this in other repo?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from translation.