Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#2 | 3388477-2.patch | 565 bytes | skyredwang |
Comments
Comment #2
skyredwangComment #3
skyredwangComment #4
ayalon CreditAttribution: ayalon at Liip commentedThanks for the patch and the good description. I was able to reproduce the issue and will include the proposed patch.
Comment #6
ayalon CreditAttribution: ayalon at Liip commentedComment #7
ayalon CreditAttribution: ayalon at Liip commented