-
Notifications
You must be signed in to change notification settings - Fork 34
Translation issue with Octane #6835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Whether it's due to circumstances or not, when this translation display problem occurs, my events (though Observer) and searches via Scout no longer works while Octane is reloaded. |
Potential solutionsI would recommend adding an event to flush loaded translation for Octane (not sure what's the side affect are to PR this to Octane right now). $translator = $event->sandbox->make('translator');
$translator->setLoaded([]); Alternatively, if you need it for your application, then you need to register it in your application service provider explicitly: this->loadJsonTranslationsFrom(lang_path('vendor/nova')); |
Hi @crynobone, Many thanks for your time and all your knowledge! It's really appreciated. I forget to mention that only these 2 keys are not translated. I've a doubt about ![]() I write this I'll try this weekend to trigger this issue without calling |
|
Okay you're right! Issue come from I set 2 endpoints: reload worker between tests
Now, uncomment https://github.com/kichetof/nova-octane-docker/blob/6cf9abdf6f6a01cea4f68122966a7bd9252f7e5f/config/octane.php#L77 who will flush
Regarding a potential solutionShould Nova need to register translations regardless if Nova is currently serving or not ? As Translations are cached, when you come from outside Nova, you'll lose these 2 translations. Or fix how these keys are resolved? Thanks for your help! |
Done in 5.6.0 |
Description:
I've finally managed to reproduce my issue with
Create :resource
andUpdate :resource
.My locale is set to French, it should display "Créer utilisateurs".
Issue happen when you call an endpoint outside of Nova with Octane enabled (FrankenPHP in my case).
video links https://github.com/kichetof/nova-octane-docker/blob/main/art/Nova-Octane-Issue.gif
Detailed steps to reproduce the issue on a fresh Nova installation:
First test:
Clone my repo, setup a user.
navigate to: http://localhost/health?fresh and you'll see some Nova translation in english (that's fine, we're outside of Nova registration)
navigate to: http://localhost/nova/resources/users and you'll see text in both language, french and english <-- issue ❌
Second test:
Take care of order
Reload worker:
sail artisan octane:reload
navigate to: http://localhost/nova/resources/users and you'll see text in french as expected
navigate to: http://localhost/health?fresh and you'll see Nova translation in french
Third test: Disable Octane
Comment this line https://github.com/kichetof/nova-octane-docker/blob/c1b6bff767e8329b9a60ca3d6d7412ba51a56f10/docker-compose.yml#L20
Restart stack: sail down && sail up -d
navigate to: http://localhost/nova/resources/users and you'll see text in french as expected no matter which endpoint you visited before.
navigate to: http://localhost/health?fresh and you'll see Nova translation in english as expected
Investigation
Create :resource
andUpdate :resource
are used in\Laravel\Nova\Resource::createButtonLabel
and\Laravel\Nova\Resource::updateButtonLabel
.Theses method are called in
\Laravel\Nova\Nova::provideToScript
via\Laravel\Nova\Nova::resourceInformation
to setupNova::$jsonVariables
Nova::$jsonVariables
are transformed inNova::jsonVariables
who is called in\Laravel\Nova\Http\Middleware\HandleInertiaRequests::share
andvendor/laravel/nova/resources/views/layout.blade.php
I suspect an issue with Request who isn't flushed between requests as it should be.
Octane flush shared properties in
\Laravel\Octane\Listeners\PrepareInertiaForNextOperation
Nova flush $jsonVariables in
\Laravel\Nova\Concerns\InteractsWithEvents::flushState
Thanks a lot for your help with this headache issue!!
The text was updated successfully, but these errors were encountered: