You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nova's own service provider registers its custom translations that way (nova 2.12.0):
class NovaServiceProvider extends ServiceProvider
{
public function boot()
{
$this->registerResources();
}
protected function registerResources()
{
$this->loadJsonTranslationsFrom(resource_path('lang/vendor/nova'));
}
// from vendor/laravel/framework/src/Illuminate/Support/ServiceProvider.php
protected function loadJsonTranslationsFrom($path)
{
$this->callAfterResolving('translator', function ($translator) use ($path) {
$translator->addJsonPath($path);
});
}
}
Translator::addJsonPath only registers a file path that will get loaded later.
Unfortunately, because HoneypotServiceProvider already used the translator, the translator will never load the additional json file.
One solution could be that the HoneypotServiceProvider gets loaded after the NovaServiceProvider.
Another way would be to load the translation only when it's needed, and not already in the boot process.
The text was updated successfully, but these errors were encountered:
I solved my problem by manually defining the service provider order in my config/app.php:
'providers' => [
// [...] my own providers here, and after them:
//translator needs to be after \Laravel\Nova\NovaServiceProvider
Laravel\Nova\NovaServiceProvider::class,
Msurguy\Honeypot\HoneypotServiceProvider::class,
],
When installing this Honeypot package, my custom translations from
.json
translation files are not available in Laravel Nova.I know of one other package that exhibits the same problem: Intervention/validation #59 and whitecube/nova-flexible-content - laravel/nova-issues/ #4192. Nova issues are: laravel/nova-issues#2505, laravel/nova-issues#2515, laravel/nova-issues#3767
The problem is that since #13, the translator is loaded when the app is booted:
Nova's own service provider registers its custom translations that way (nova 2.12.0):
Translator::addJsonPath
only registers a file path that will get loaded later.Unfortunately, because HoneypotServiceProvider already used the translator, the translator will never load the additional json file.
One solution could be that the HoneypotServiceProvider gets loaded after the NovaServiceProvider.
Another way would be to load the translation only when it's needed, and not already in the boot process.
The text was updated successfully, but these errors were encountered: