Skip to content

Commit

Permalink
[4.x] Localize entry & term fields in Taxonomy Term GraphQL queries (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean authored Feb 8, 2024
1 parent b1bb52b commit f77064c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Fieldtypes/Entries.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Statamic\Search\Index;
use Statamic\Search\Result;
use Statamic\Support\Arr;
use Statamic\Taxonomies\LocalizedTerm;

class Entries extends Relationship
{
Expand Down Expand Up @@ -321,7 +322,7 @@ protected function collect($value)
public function augment($values)
{
$site = Site::current()->handle();
if (($parent = $this->field()->parent()) && $parent instanceof Localization) {
if (($parent = $this->field()->parent()) && ($parent instanceof Localization || $parent instanceof LocalizedTerm)) {
$site = $parent->locale();
}

Expand Down
3 changes: 2 additions & 1 deletion src/Fieldtypes/Terms.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Statamic\Query\Scopes\Filters\Fields\Terms as TermsFilter;
use Statamic\Support\Arr;
use Statamic\Support\Str;
use Statamic\Taxonomies\LocalizedTerm;

class Terms extends Relationship
{
Expand Down Expand Up @@ -111,7 +112,7 @@ public function augment($values)
// entry, but could also be something else, like another taxonomy term.
$parent = $this->field->parent();

$site = $parent && $parent instanceof Localization
$site = $parent && ($parent instanceof Localization || $parent instanceof LocalizedTerm)
? $parent->locale()
: Site::current()->handle(); // Use the "current" site so this will get localized appropriately on the front-end.

Expand Down

0 comments on commit f77064c

Please sign in to comment.