This repository has been archived by the owner on Jun 18, 2019. It is now read-only.
example in doc for locale filtering in whereTranslation scope #487
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
whereTranslation
scope allows for a third parameter$locale
that filters translations in that locale.I needed that feature to filter slugs in specific locales.
Example:
example.com/map
-> map page in englishexample.com/sv/karta
-> map page in swedishThe problem is that I was querying the pages model using the slug and
sv/map
would return (correctly) the map page instance, but that's not a correct locale/slug combination.To make that work using the provided scope it should filter also by locale, which that third parameter enables.
I wasn't aware of it until I went into the source code to try and fix my problem, and the "fix" was already there.
Docs updated so that anybody with the same issue is aware of the option.