Closed k2idev closed 4 years ago
Nova’s translation system is designed to be used with Laravel’s JSON translations, not the array based ones.
Ok - still seems strange that it works in 3.7.1 and stops working in 3.8.2 ?
Maybe add a hint in the documentation that when there is no translation for a model name in the JSON file (resources/lang/vendor/nova
), Nova goes looking for a php based file with the model name in the translation directory (resources/lang/en
) and returns the array from that file which breaks translation and navigation.
https://nova.laravel.com/docs/3.0/customization/localization.html#overview
Description:
I upgraded from Nova 3.7.1 to 3.8.2 and now Nova is unable to show the dashboard
because "htmlspecialchars() expects parameter 1 to be string, array given"
in vendor/laravel/nova/resources/views/resources/navigation.blade.php
My understanding of the issue
I have a Model name 'Module' It is registered in Nova as public static $model = 'App\Module';
When I open the dashboard in Nova an error occurs.
The error occurs in this line in
navigation.blade.php
(line 24){{ $resource::label() }}
What seems to be happening is that
label()
tries to translate the name of the model with__('Modules')
The helper function__()
does this:return app('translator')->get($key, $replace, $locale);
and tries to get the translation.In
ressources/lang/en
I have a file calledmodules.php
Now the problem is that
app('translator')->get($key, $replace, $locale)
returns the content of this file and not the translation.This breaks navigation.blade.php with the "expected string but got array" because
app('translator')->get(..)
returnsinstead of
'Modules'
public static function label()
in Nova/Module.phpressources/lang/en/modules.php
But it seems that this is bug(?) and should not happen - and it works fine in v 3.7.1
PS: Sorry if there are any formal mistakes in reporting this issue (it's the first time I am doing this :))