Open votemike opened 5 months ago
I'm having the same problem: V 10.7.0 (and in latest)
@votemike I figured out my issue. I had to continue digging down into the nested fields. Our Page
content model has a content
field. The localized content is nested in that content field. That means we had to dig deeper to get our localized fields e.g.
entry.fields.content['en-US'].fields.title['pt-BR']
I hope maybe that helps but not sure if it's the same for you.
@votemike I figured out my issue. I had to continue digging down into the nested fields. Our
Page
content model has acontent
field. The localized content is nested in that content field. That means we had to dig deeper to get our localized fields e.g.entry.fields.content['en-US'].fields.title['pt-BR']
I hope maybe that helps but not sure if it's the same for you.
Is that while you are querying the API?
Yeah, so entry
is a result of mapping items
from:
const {items} = await this.client.withAllLocales.getEntries<PageEntrySkeleton>(query)
So what query are you using to query the pt-BR title?
const query = {
content_type: 'page',
'fields.path': path,
include: 5,
limit: 1,
}
This get's our Page
and child models, then entry
is items[0]
Ahh, so you query by path (which I guess is the same in all locale's) and then choose the pt-BR localisation of the title.
Expected Behavior
Querying with withAllLocales should query on all translations. E.G.
Should return my results for any localised url.
Actual Behavior
The query mentioned above only works if querying url specified in the default locale language.
Possible Solution
Steps to Reproduce
Set up Contentful with a default language and a language that falls back to the default language. Create a model with a translatable URL field. Add an entry with with only a url in the default language Add an entry with with a url in both languages Query based on non-default url.
Context
I have several pages that can be in several languages. Sometimes I want all languages to use the same URL. Sometimes I want each language to have a unique URL. I want to retrieve the page by URL. I cannot pass the locale in to the query, as locales with no URL translation will not fallback to the default language url for querying purposes.
Environment