Localized content models for entry-level localization

Hello there,

I’m trying to implement the entry-level localization patter as described here: Locales | Contentful

As the article suggests, I have a “Page (Global)” content model that contains an internal title and a localized reference to another content model restricted to content from another “Page (Local)” content type.

Now I’m wondering whether or not I need to enable localization on each of the fields in the “Page (Local)” content model. The article doesn’t really mention it, but I’m guessing I shouldn’t be doing that?

However, if I don’t enable localization on each and every field in the “Page (Local)” model (and all potentially nested models), I can’t find a way to retrieve just one locale via the API (I always get every locale).

How should I model the “Page (Local)” content model? Is there an example for entry-level localization around that I could use for inspiration?

1 Like

Hello Roman - unfortunately I don’t know the API answer you seek, but in case helpful in any way for your task at hand, you can try our translations app for Contentful: https://www.contentful.com/marketplace/app/translations-by-acclaro/ where you can create an Export/Import translation order, select Entry Level localization, select Entries and choose a target locale to export source content.

Did you ever figure this out? I have the exact same questions.

It seems like that article would be significantly less confusing if their screenshots included the translation and field-level settings. I also need to be able to explain to non-technical writers whether they can or should be writing non-English languages into fields that the translation menu bar suggests are English only for the localized posts.

There’s a video here going through entry-level localization that’s a little more helpful: Using localization with Contentful : Contentful Learning Center.

It doesn’t specifically address your question, but based on the screenshots, I think the fields in the local posts content model do not have the “Enable localization of this field” checked. So, when you’re creating the content of a local post, I guess the translation box is just ignored. If English is the default language, I think the translation box acts like you can only enter values in English, despite the fact that you’re treating the entire localized post as if it is in a language other than English.

EDIT

After playing around with this via the API client wrapper, I can’t imagine this is what Contentful intended. When I getEntries via Node, there seems to be no way to tell that the localized version of this post is associated with that locale. So, the published German article in an English default account has nothing in the API to attach it to German – instead, the locale is still English. Also, the global entry doesn’t even seem to link to the hypothetical published German article?

We have exactly the same concern.

I can’t imagine this is what Contentful intended. There seems to be no way to tell that the localized version of this post is associated with an specific locale (not the default). So, the published German article in an English default account has nothing in the API to attach it to German – instead, the locale is still English.

Please Contentful team, explain what is the intended behavior.

The key portion of the entry-level localization concept is this:

How does localization fit into this picture? Instead of localizing text fields, as in the case of field-level localization, one localizes the reference field. This way, the article aggregate refers to one Article - Local entry in US-English and another in DE-German

It’s true the text is a bit confusing, but the idea is that only the reference field to local articles on the global article content type is localized and none of the fields on the local article content type are localized. Here’s a diagram which perhaps explains it better than words:

Regarding the API response, in order to find the desired local article you need to query for the global article and specify the desired locale to filter for the specific localized version of the local article you want.

For example, if I query for an entry of the global article content type with a certain name and specify that I want the English version, like so:

client.getEntries({
    "content_type": "globalArticle",
    "fields.name": "global article title",
    "locale": "en"
})

Then the response includes only the English local article:

{
  sys: {
...
    locale: 'en'
  },
  fields: {
    name: 'global article title',
    localArticle: {
      sys: {
...
        locale: 'en'
      },
      fields: {
        title: 'en local article title',
        intro: 'en local article intro',
        body: {
...
          nodeType: 'text',
          value: 'en local article body',
          marks: [],
          data: {}
...

Similarly, if you query for the German version like so:

client.getEntries({
    "content_type": "globalArticle",
    "fields.name": "global article title",
    "locale": "de-DE"
  })

Then the response only includes the German local article:

{
  sys: {
...
    locale: 'de-DE'
  },
  fields: {
    name: 'global article title',
    localArticle: {
      sys: {
...
        locale: 'de-DE'
      },
      fields: {
        title: 'de-DE local article title',
        intro: 'de-DE local article intro',
        body: {
...
          nodeType: 'text',
          value: 'de-DE local article body',
          marks: [],
          data: {}
...

I hope this helps explain the concept better.