Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: DOCU-2700

...

alignright
classmenu

This page describes how you can request localized content with the Delivery endpoint API.

In Magnolia REST 2.1.x, version 2 of the delivery endpoint allows you to send an API request for a specific language variant of content. This is different from the previous implementation (REST 2.0.x), in which the endpoint version 1 always delivered all language variants available in the JCR repository.

Warning

For i18n features to work correctly, check that the fallback site has locales configured or extends a site definition with desired locales.

Table of Contents

Specifying the language

...

Multiexcerpt
MultiExcerptNameusage-summary

To request a specific single language variant, do one of the following:

  • Set the Accept-Language header. For example:  Accept-Language: de-DE
  • Set the langquery parameter. For example: lang=de-DE

If both are set, the lang parameter takes priority. If neither is set, the decision is delegated to the I18nContentSupport interface.

To return all language variants:

  • Set the lang query parameter to all: lang=all

You can use both the Accept-Language header and the lang query parameter for both sub-resources Read node and Query nodes.

...

The example requests below make use of the title and title_de properties of the /travel/about page in the Travel Demo.

The reponses are returned based on the following configuration:

...

If neither the header or the lang query parameters is used in the request, the language used for the response refelcts the locale determined by the the I18nContentSupport interface.

Accept-Language header

Request URL

JSON response

not set

/.rest/ep/travel/about

Code Block
languagejs
{
 "@name": "about",
 "@path": "/travel/about",
 "@id": "808ebe4c-72b2-49f1-b9f7-e7db22bce02f",
 "@nodeType": "mgnl:page",
 "hideInNav": "false",
 "title": "About",
 "@nodes": []
}

The language is not defined by the header or the lang parameter. The value returned for title is determined by the I18nContentSupport interface.

...