Add language support

Created on 11 July 2017, almost 7 years ago
Updated 27 October 2023, 8 months ago

Could you add the language property in the response?
I'm using translated menu items and I need to expose this information.

Thanks!

✨ Feature request
Status

Closed: works as designed

Version

1.0

Component

Code

Created by

🇮🇹Italy arrubiu

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇱Netherlands batigolix Utrecht

    This needs to be reviewed, but note that this is quite an old patch

  • Assigned to undersound3
  • 🇳🇱Netherlands undersound3
  • Issue was unassigned.
  • Status changed to Closed: works as designed 8 months ago
  • 🇳🇱Netherlands undersound3

    I just tested this a bit more on Drupal 9.5.10 and Rest Menu Items 3.0.x and things seem to work fine.
    I have noticed though the following though...

    Adding a language next to the default language (in this example I use EN as the default language and NL as the second language) does not necessarily mean that /en/api/menu_items/{menu_name} is working. I was getting the same error as mentioned in https://www.drupal.org/project/rest_menu_items/issues/2893872#comment-13... ✨ Add language support Closed: works as designed

    {
      "message": "No route found for \"GET \/en\/api\/menu_items\/footer\""
    }

    The following links were working though
    /api/menu_items/{menu_name}
    /nl/api/menu_items/{menu_name}

    It wasn't until I switched the default language from EN to NL that /en/api/menu_items/{menu_name} started to work.
    Obviously because NL was now the default language. Then I switched the default language back to EN and all of the following links started to work.

    /api/menu_items/{menu_name}
    /en/api/menu_items/{menu_name}
    /nl/api/menu_items/{menu_name}

    So it seems changing the default language seems to change the endpoints available.

    Besided this I am getting aliases returned like this:

    EN
    https://drupal9.ddev.site/api/menu_items/footer?_format=json

    [
    {
    key: "04e0718c-2c0e-4f2c-a8d8-0b12cf5dee55",
    title: "Article #1 EN",
    description: null,
    uri: "node/1",
    alias: "article-1",
    external: false,
    absolute: "https://drupal9.ddev.site/en/article-1",
    relative: "/en/article-1",
    existing: true,
    weight: "0",
    expanded: false,
    enabled: true,
    uuid: "f54a223e-4682-470c-8c59-d70dd54c28c5",
    options: [ ]
    },
    {
    key: "d217e9f6-f1d2-4371-8d14-c883f7b0c78e",
    title: "Article #2 EN - non translated",
    description: null,
    uri: "node/2",
    alias: "article-2-non-translated",
    external: false,
    absolute: "https://drupal9.ddev.site/en/article-2-non-translated",
    relative: "/en/article-2-non-translated",
    existing: true,
    weight: "0",
    expanded: false,
    enabled: true,
    uuid: "bea04fee-d11a-4818-8a8c-a95f08dc4330",
    options: [ ]
    },
    {
    key: "18c38a8b-da0d-448d-834d-fd9eb2de911d",
    title: "Front",
    description: null,
    uri: "",
    alias: "",
    external: false,
    absolute: "https://drupal9.ddev.site/en",
    relative: "/en",
    existing: true,
    weight: "0",
    expanded: false,
    enabled: true,
    uuid: null,
    options: [ ]
    },
    {
    key: "c32a9f45-77f1-4112-9cfb-3d077d2d93ea",
    title: "Untranslated menu item",
    description: null,
    uri: "node/1",
    alias: "article-1",
    external: false,
    absolute: "https://drupal9.ddev.site/en/article-1",
    relative: "/en/article-1",
    existing: true,
    weight: "0",
    expanded: false,
    enabled: true,
    uuid: "f54a223e-4682-470c-8c59-d70dd54c28c5",
    options: [ ]
    }
    ]

    NL
    https://drupal9.ddev.site/nl/api/menu_items/footer?_format=json

    [
    {
    key: "04e0718c-2c0e-4f2c-a8d8-0b12cf5dee55",
    title: "Article #1 NL",
    description: null,
    uri: "node/1",
    alias: "article-1",
    external: false,
    absolute: "https://drupal9.ddev.site/nl/article-1",
    relative: "/nl/article-1",
    existing: true,
    weight: "0",
    expanded: false,
    enabled: true,
    uuid: "f54a223e-4682-470c-8c59-d70dd54c28c5",
    options: [ ]
    },
    {
    key: "d217e9f6-f1d2-4371-8d14-c883f7b0c78e",
    title: "Article #2 EN - non translated",
    description: null,
    uri: "node/2",
    alias: "node/2",
    external: false,
    absolute: "https://drupal9.ddev.site/nl/node/2",
    relative: "/nl/node/2",
    existing: true,
    weight: "0",
    expanded: false,
    enabled: true,
    uuid: "bea04fee-d11a-4818-8a8c-a95f08dc4330",
    options: [ ]
    },
    {
    key: "18c38a8b-da0d-448d-834d-fd9eb2de911d",
    title: "Front",
    description: null,
    uri: "",
    alias: "",
    external: false,
    absolute: "https://drupal9.ddev.site/nl",
    relative: "/nl",
    existing: true,
    weight: "0",
    expanded: false,
    enabled: true,
    uuid: null,
    options: [ ]
    },
    {
    key: "c32a9f45-77f1-4112-9cfb-3d077d2d93ea",
    title: "Untranslated menu item",
    description: null,
    uri: "node/1",
    alias: "article-1",
    external: false,
    absolute: "https://drupal9.ddev.site/nl/article-1",
    relative: "/nl/article-1",
    existing: true,
    weight: "0",
    expanded: false,
    enabled: true,
    uuid: "f54a223e-4682-470c-8c59-d70dd54c28c5",
    options: [ ]
    }
    ]
    

    I do see however that when a node has no translation the internal path is returned and not the alias of the node of the default language.
    I guess we need to decide if that is the responsibility of this module or drupal core?

Production build 0.69.0 2024