Reputation: 3833
For somewhat reason Laravel won't return the string but simply the key:
Here is my messages.php saved in /resources/lang/en/
return[
'Example' => 'Ejemplo',
'Otroejemplo' => 'Beispiel',
];
This is my routing:
Route::get('myexample/{locale}', function ($locale) {
App::setLocale($locale);
return view('admin.pages.forms.myexample');
});
And this is myexample.blade.php:
@lang('messages.Example');
I expect to get Ejemplo in return when I open localhost:8000/myexample/en but I get message.Example instead.
Upvotes: 2
Views: 204
Reputation: 2474
Tested your code, it's working fine the only issue I got is instead of
Route::get('myexample/{locale}', function ($locale) {
App::setLocale($locale);
return view('admin.pages.forms.myexample');
});
use
Route::get('myexample/{locale}', function ($locale) {
App::setLocale($locale);
return view('myexample'); // in case your view is in resources folder
});
Upvotes: 2