@@ -382,18 +382,22 @@ public static function getPublishAction(): Action
382382 $ livewire ->data ['translation_status ' ] = 'published ' ;
383383 $ livewire ->save ();
384384
385- if (method_exists ($ livewire ->record , 'translateOrNew ' )) {
386- $ locale = app ()->getLocale ();
387- $ translation = $ livewire ->record ->translateOrNew ($ locale );
388- $ translation ->published_at = now ();
389- $ translation ->publishedBy ()->associate (auth ()->user ());
390- $ translation ->to_publish_at = null ;
391- $ translation ->unpublished_at = null ;
392- $ translation ->to_unpublish_at = null ;
393- $ translation ->save ();
394- }
385+ if (method_exists ($ livewire ->record , 'translateOrNew ' )) {
386+ $ locale = $ livewire -> lang ?? app ()->getLocale ();
387+ $ translation = $ livewire ->record ->translateOrNew ($ locale );
388+ $ translation ->published_at = now ();
389+ $ translation ->publishedBy ()->associate (auth ()->user ());
390+ $ translation ->to_publish_at = null ;
391+ $ translation ->unpublished_at = null ;
392+ $ translation ->to_unpublish_at = null ;
393+ $ translation ->save ();
394+ }
395395
396- $ livewire ->redirect (static ::getUrl ('view ' , ['record ' => $ livewire ->record ]));
396+ $ url = static ::getUrl ('view ' , ['record ' => $ livewire ->record ]);
397+ if (isset ($ livewire ->lang )) {
398+ $ url .= '?lang= ' . $ livewire ->lang ;
399+ }
400+ $ livewire ->redirect ($ url );
397401 })
398402 ->visible (fn ($ livewire ): bool => $ livewire instanceof EditRecord)
399403 ->hidden (fn ($ get , $ livewire ) => $ get ('translation_status ' ) === 'published '
@@ -413,7 +417,12 @@ public static function getSaveAndCreateAnotherAction(): Action
413417 ->button ()
414418 ->action (function ($ livewire ): void {
415419 $ livewire instanceof CreateRecord ? $ livewire ->create () : $ livewire ->save ();
416- $ livewire ->redirect (static ::getUrl ('create ' ));
420+
421+ $ url = static ::getUrl ('create ' );
422+ if (isset ($ livewire ->lang )) {
423+ $ url .= '?lang= ' . $ livewire ->lang ;
424+ }
425+ $ livewire ->redirect ($ url );
417426 })
418427 ->visible (fn ($ livewire ): bool => $ livewire instanceof CreateRecord);
419428 }
0 commit comments