Did you perhaps change your fallback locale ? If the locale and fallback locale is set to a language where it isnt translated, it just shows the "key"
https://github.com/laravel/laravel/blob/9.x/config/app.php#L98
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello all,
I have validation, previously it was running correctly. But after that result becomes validation.required, even though I didn't change any settings.
Laravel 9.7.0
image : https://ibb.co/fpQCDhW
Did you perhaps change your fallback locale ? If the locale and fallback locale is set to a language where it isnt translated, it just shows the "key"
https://github.com/laravel/laravel/blob/9.x/config/app.php#L98
I've checked, value is still same.
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'en',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'fallback_locale' => 'en',
and clear config still not working
php artisan config:clear
@gzai Check your en/validation.php file for the required key then. Its in your lang directory (either in /lang or /resources/lang. It was moved in laravel 9)
lang/en/validation.php
'regex' => 'The :attribute format is invalid.',
'required' => 'The :attribute field is required.',
'required_array_keys' => 'The :attribute field must contain entries for: :values.',
'required_if' => 'The :attribute field is required when :other is :value.',
for directory :
root
-- lang
---- en
------ auth.php
------ pagination.php
------ passwords.php
------ validation.php
-- resources
---- lang
------ vendor
@gzai Can you try running dd(trans('validation.requried')); in a controller and see what you get?
^ "validation.requried"
I've tried deleting the vendor folder and reinstalling, but it still doesn't work
@gzai Indeed weird. How about dd(app()->getLocale());
^ "en"
@gzai I honestly have no clue. I cannot recreate it in a laravel 9 project..
I dont suppose this is an opensource project so I can inspect the code on github ?
thanks @Sinnbeck,
I will check again all my code. If I find the problem and fix it, I will let anyone know.
@gzai Are you sure its laravel 9 and not 8? If it was 8 it would not be able to find the /lang folder. Does your other translations work as expected?
Do you have an en.json file perhaps that is messing it up (you can try renaming it)
@Sinnbeck , yeah I'm pretty sure its laravel 9
php artisan --version
Laravel Framework 9.7.0
composer.json
"require": {
"php": "^8.0.2",
"artesaos/seotools": "^0.22.0",
"barryvdh/laravel-elfinder": "^0.5.1",
"cybercog/laravel-ban": "^4.7",
"guzzlehttp/guzzle": "^7.2",
"jantinnerezo/livewire-alert": "^2.2",
"jenssegers/agent": "^2.6",
"laravel/framework": "^9.2",
"laravel/jetstream": "^2.6",
"laravel/sanctum": "^2.14.1",
"laravel/socialite": "^5.5",
"laravel/tinker": "^2.7",
"livewire/livewire": "^2.5",
"maatwebsite/excel": "^3.1",
"mtvs/eloquent-hashids": "^3.2",
"niklasravnsborg/laravel-pdf": "^4.1",
"owen-it/laravel-auditing": "^13.0",
"power-components/livewire-powergrid": "^2.4",
"psr/simple-cache": "1.0",
"pusher/pusher-php-server": "^7.0",
"spatie/laravel-permission": "^5.5",
"spatie/laravel-sitemap": "^6.1"
},
Does your other translations work as expected? everything is not working as expected.
e.g. :
$validated = $request->validate([
'name' => 'required|numeric|max:255',
]);
// type input : abcde
// result : validation.numeric
after renaming en.json to fr.json and config:clear, it still doesn't work.
lang/en/en.json
{
"The :attribute must contain at least one letter.": "The :attribute must contain at least one letter.",
"The :attribute must contain at least one number.": "The :attribute must contain at least one number.",
"The :attribute must contain at least one symbol.": "The :attribute must contain at least one symbol.",
"The :attribute must contain at least one uppercase and one lowercase letter.": "The :attribute must contain at least one uppercase and one lowercase letter.",
"The given :attribute has appeared in a data leak. Please choose a different :attribute.": "The given :attribute has appeared in a data leak. Please choose a different :attribute."
}
@gzai So you are only using translations for validation?
@Sinnbeck yes, I only using translations for validation. it's so weird.
@gzai Is there anything in your service providers that could tamper with it? Check each one. Or a package that helps with translations somehow?
You dont by any chance have xdebug?
@Sinnbeck this so weird.
I just copied en folder in lang folder, and pasted it into resources/lang folder, the result is as expected.
current structure :
root
--- lang
------ en
--------- auth.php
--------- pagination.php
--------- passwords.php
--------- validation.php
------ en.json
--- resources
------ lang
--------- en
------------ auth.php
------------ pagination.php
------------ passwords.php
------------ validation.php
--------- vendor
I compared the structure of laravel 9 (fresh install with same package list) with structure of my project using winMerge. no strange differences.
how is it possible to add en folder into resource/lang folder and the result can be as expected? it's very wrong in laravel 9 structure?
@gzai do you mean it works now or?
@gzai This test didn't work because you spelled required incorrectly.
@Sinnbeck yes, it's works now.
but I have to copy en folder into resources/lang folder.
@Snapey doh my bad. Nicely spotted.
@gzai that's where it has been until laravel 9, so that should work. Do you care that it's there instead of in root? https://laravel.com/docs/9.x/upgrade#the-lang-directory
I have no clue why your version only works with the old path, and I doubt I can give a solution without having access to the code
@gzai awesome.
I misspelled it here
Can you try running dd(trans('validation.requried')); in a controller and see what you get?
If I running this code in controller, with structure like this :
root
--- lang
--- resources
------ lang
--------- vendor
------------ livewire-powergrid
dd(trans('validation.required'));
// result
^ "validation.required"
but, if I delete lang folder inside resources folder
root
--- lang
--- resources
dd(trans('validation.required'));
// result
^ "The :attribute field is required."
it seems because the package hasn't changed the target publish language file yet into lang folder in root.
@gzai ah makes sense. I believe laravel checks both locations for now, so just leave it in the old location
@Sinnbeck Looks like Laravel checks both locations, but it will be prioritized if found lang folder in resources folder.
@gzai yeah most likely for legacy reasons :) if it's working you can mark the thread as solved by marking a best answer
big thanks @Sinnbeck :)
@gzai I had a similar problem a while ago and the issue was the lang directory in the resources folder. Deleted it and it went back to normal
Hey, came across this same issue and the only thing that worked was copying the lang folder to the resources folder (Laravel 9)
Please or to participate in this conversation.