Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hello,
I've met an issue during development of world-wide shop based on Storefront API 2022-01.
When I try to get translated Product response using header:
"Accept-Language": "de"
with given region using:
@inContext(country: DE)
I get correct price (in EURO), but fields from query (title, description etc.) aren't translated.
The only way to get fields translated from Storefront API is to remove the @inContext from query.
Am I doing something wrong? Is there a solution for that?
My sample query, tested with Storefront API 2022-01:
query @inContext(country: DE) {
node(id: "[PRODUCT_ID]") {
id
...on Product {
title
priceRange {
maxVariantPrice {
currencyCode
}
}
}
}
}
Response:
{
"data": {
"node": {
"id": "[PRODUCT_ID]",
"title": "[ENGLISH PRODUCT TITLE]",
"priceRange": {
"maxVariantPrice": {
"currencyCode": "EUR"
}
}
}
},
"extensions": {
"context": {
"country": "DE",
"language": "DE"
}
}
}
From what I can see there is a new @inContext parameter called "language" in 2022-04 version, so I can type:
@inContext(country: DE, language: DE)
But I still get response with English values:
{
"data": {
"node": {
"id": "[PRODUCT_ID]",
"title": "[ENGLISH PRODUCT TITLE]",
"priceRange": {
"maxVariantPrice": {
"currencyCode": "EUR"
}
}
}
},
"extensions": {
"context": {
"country": "DE",
"language": "EN"
}
}
}