Problem/Motivation

Language code can have two parts, like en-GB or zh-hans. We want to support this format

Steps to reproduce

1. Enable a language with dialect, e.g. zh-hans
2. Make translations for a node
3. Query the node with a specific translation, example query below

query MyQuery {
  entityQuery(
    entityType: NODE
    filter: {conditions: {field: "type", value: "article"}}
  ) {
    items {
      ... on NodeArticle {
        id
        translation(langcode: ZH_HANS) {
          label
        }
      }
    }
  }
}

Notice the language ENUM `ZH_HANS`, it was defined with the underscore. This underscore isn't converted back to hyphen when the server receives the query.

Therefore, you cannot get this specific translation

Proposed resolution

Correctly convert the language ENUM back to the code used by Drupal

Remaining tasks

Make a patch

User interface changes

None

API changes

None

Data model changes

None

CommentFileSizeAuthor
#2 3388477-2.patch565 bytesskyredwang
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

skyredwang created an issue. See original summary.

skyredwang’s picture

Status: Active » Needs review
FileSize
565 bytes
skyredwang’s picture

Issue summary: View changes
ayalon’s picture

Thanks for the patch and the good description. I was able to reproduce the issue and will include the proposed patch.

  • ayalon committed 523f9368 on 1.0.x
    Issue #3388477 by skyredwang, ayalon: Translation is broken for...
ayalon’s picture

Status: Needs review » Fixed
ayalon’s picture

Status: Fixed » Closed (fixed)