Contentful logo

Contentful Community

Search in all locales

localization
#1

Hello,
I have urls on my app that look like this https://myapp.com/<locale>/<entry_slug>
To build a page, I use contentful API to search for an entry with slug=<entry_slug>

I’d like to enable localization for the slug field so an entry could look like:

{slug:{ en: 'mySlug-en', fr: 'mySlug-fr' }

Now let’s say the user is on page:
https://myapp.com/en/mySlug-en

My issue is that if the user changes the locale to let’s say french, then the language switch will navigate to:
https://myapp.com/fr/mySlug-en

But mySlug-en won’t match any entry for locale fr.

If contentful API could search for slug=mySlug-en in any locale then I could get my content and redirect the user to https://myapp.com/fr/mySlug-fr

0 Likes