Skip to content
This repository has been archived by the owner on Jan 4, 2025. It is now read-only.

Drupal module that adds path of alternate languages to JSON:API resource responses.

Notifications You must be signed in to change notification settings

wunderwerkio/drupal-jsonapi-locale-info

Repository files navigation

Important Notice

The version control was moved to Drupal's GitLab instance!
See https://www.drupal.org/project/jsonapi_locale_info for more info!


JSON:API Locale Info

Lint & Test Quality Gate Status

This module adds localization metadata to JSON:API resources that support translation and have path aliases enabled.

In particular, the following data is added in the media section in the API response:

  • localeInfo Is an array of languages this resource is also available (but not including the current language). Each array item contains the langcode and the localized path for that language.

Example Response

Given the following settings:

  • Default locale: en
  • Additional languages: de

When requesting a node with the default language, the output is as follows:

{
  "jsonapi": {
    // ...
  },
  "data": {
    "attributes": {
      // ...
      "path": {
        "alias": "/my-node",
      }
    },
    // ...
    "meta": {
      "localeInfo": [
        {
          "langcode": "de",
          "path": "/meine-node"
        }
      ]
    }
  }
}

About

Drupal module that adds path of alternate languages to JSON:API resource responses.

Resources

Stars

Watchers

Forks

Packages

No packages published