Having trouble to translate validation rules into Spanish
Hello.
I develop everything in English (names for tables, fields, etc., ) and I translate to Spanish. I had been using in version 2 just changing the locale in config\app.php. It changes into Spanish quite a lot of things but I keep finding new ones every day. I mean, thins that are not translated at all.
For example, validation rules.
I have found a file in vendor\laravel\framework\src\Illuminate\Translation\lang\en
and I have duplicated it into a new folder inside the same place with the name ==> vendor\laravel\framework\src\Illuminate\Translation\lang\es
and inside there I have changed some of the rules that I need to be translated.
Also, as other examples, when I put the ->passwordReset() in the panel, everything new appears in English. The clickable link label is NOT translated, if you click, the WHOLE new form in NOT TRANSLATED, etc.
That makes me think that I MUST BE DOING THINGS WRONG, very probably. I cannot believe nobody has ever before translated into Spanish the phrase ==> Forgot your password?
Maybe my approach to the language, with the basic steps:
1. Change locale is config\app.php
2.Created a new file at lang\es.json where I type the translations for my fields names and so on.
and the rest is try to keep correcting and finding solutions to whatever new problems I find and then I have changed files in:
vendor\laravel\framework\src\Illuminate\Translation\lang\en
vendor\filament\filament\resources\lang\es\pages\auth\login.php
etc.
Any ideas or suggestions on WHY my APPROACH is not the right one, please? this is making me waste a lot of time in just translations.
Tks a lot.
9 Replies
NEVER NEVER edit vendor files
try using this package to add your needed language https://github.com/Laravel-Lang/lang
it helped me yesterday
Tks. Ok. I'll try with that.
It has not solved the problem.
I have used:
composer require laravel-lang/common --dev
php artisan lang:add es
and
php artisan lang:update
Maybe all the problem is caused because I have already changed many files manually. I do not Know, but this does not solve the problem.
Profile is in English, Register blade page shows only English, etc.
remove all files that you already added or updated
this package adds validation messages translations
and changing lang in
confi/app.php
should work
You can also add a language switcher to the panel
There's a plugin for that. Check filament pluginsI will try but I am a bit frightened that other things stop working. I really have quite a lot of work done. And I don't know how to discover exactly which files from VENDORs I changed. Is there any instruction to find out that?
NEVER change vendor files
if you changed them well you are screwd
Ok. I will begin a new project from scratch and then I will recover some migrations and Resources from one directory to another.
if you will run
composer update
everything in the vendor possibly will be updatedAlso, as other examples, when I put the ->passwordReset() in the panel, everything new appears in English. The clickable link label is NOT translated, if you click, the WHOLE new form in NOT TRANSLATED, etc.Might be that there are translations in ES missing for Filament v3. Check the contribution guide on the readme to see how to PR translations.
Great!
I executed (in a brand new project from scratch)
php artisan filament:check-translations es
And see there are quite a few missing translations.
I am not really good at managing GitHub, but I will try to fork it and if I can make those translations myself and can contribute in some way to this project, it will be perfect for me. I will then make a PR (Which I understand is a Pull Request)