Skip to content

Commit

Permalink
[4.x] Use the site locale when auto generated titles (#9261)
Browse files Browse the repository at this point in the history
Use the site locale when generating title formats
  • Loading branch information
ryanmitchell authored Jan 5, 2024
1 parent d9c994a commit efcf3f9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Entries/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Responsable;
use Illuminate\Support\Carbon;
use Illuminate\Support\Traits\Localizable;
use LogicException;
use Statamic\Contracts\Auth\Protect\Protectable;
use Statamic\Contracts\Data\Augmentable;
Expand Down Expand Up @@ -53,7 +54,7 @@

class Entry implements Arrayable, ArrayAccess, Augmentable, ContainsQueryableValues, Contract, Localization, Protectable, ResolvesValuesContract, Responsable, SearchableContract
{
use ContainsComputedData, ContainsData, ExistsAsFile, FluentlyGetsAndSets, HasAugmentedInstance, Publishable, Revisable, Searchable, TracksLastModified, TracksQueriedColumns, TracksQueriedRelations;
use ContainsComputedData, ContainsData, ExistsAsFile, FluentlyGetsAndSets, HasAugmentedInstance, Localizable, Publishable, Revisable, Searchable, TracksLastModified, TracksQueriedColumns, TracksQueriedRelations;

use HasOrigin {
value as originValue;
Expand Down Expand Up @@ -926,7 +927,7 @@ public function autoGeneratedTitle()

// Since the slug is generated from the title, we'll avoid augmenting
// the slug which could result in an infinite loop in some cases.
$title = (string) Antlers::parse($format, $this->augmented()->except('slug')->all());
$title = $this->withLocale($this->site()->locale(), fn () => (string) Antlers::parse($format, $this->augmented()->except('slug')->all()));

return trim($title);
}
Expand Down

0 comments on commit efcf3f9

Please sign in to comment.