Locales
Locales allow you to define translatable content for assets and entries. A locale includes the following properties:
-
name: A human readable identifier for a locale. For example, ‘British English’. -
code: An identifier used to differentiate translated content in API responses. For example, ‘en-GB’. -
fallbackCode: The code of the locale to use if there is no translated content for the requested locale. For example,en-US. You can set it tonullif you don’t want a default locale. This can only be set via the API, and not with the web app or client libraries.
Locale collection
The locales endpoint returns a list of all created locales. One will have the flag default set to true and is the locale used in the CDA, and you specified no other locale in the request.
Locale-based publishing
Use the X-Contentful-Locale-Based-Publishing request header to opt in to locale-based publishing.
When this header is present, only published locales will be returned. Publishing status is determined from entry.sys.fieldStatus in the Content Management API.
Behavior
-
The header applies to both
EntryandAssettypes. -
For entry-level publishing, enabling this header doesn’t change the existing response behavior — the content will be returned as previously without the header.
-
Fallback locales are not used to determine publishing status, but only for content resolution. If a requested locale is unpublished, a published fallback locale doesn’t make it visible in the response.
-
When a locale is added to a space, affected entries must be republished before that locale appears in CDA responses. Republish the locale where locale-based publishing is available, or republish the entry for entry-level publishing.
Examples
Request a published and draft locale
The following Content Management API entry has one published locale and one draft locale:
When the locale-based publishing header is enabled, a CDA request for the published en-US locale returns the entry:
A CDA request for the draft de-DE locale does not return the entry:
Request unpublished and changed locales
The following example space has three enabled locales: en-US, de-DE, and nl-NL.
entry1 is published only in en-US. After publishing, entry1 was edited again in en-US, so its en-US status is changed. The de-DE and nl-NL locales are not published for entry1.
entry2 is published in both en-US and de-DE. This doesn’t affect which locales are visible for entry1.
Fetching an unpublished locale for entry1 returns a 404 response:
Fetching another unpublished locale for entry1 also returns a 404 response:
Fetching the published en-US locale for entry1 returns a 200 response. Because the locale has unpublished changes, the CDA response contains the last published value, not the post-publish edit.