Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Our store installed "Translate & Adapt" already. we can request and get exactly translation with the right iso code "ZH" on the first week. However, can't get the match translated product content anymore after first week whatever we do update the products translation. Now, storefront only return the english content, even we pass the "ZH" code. And we have had checked the supporting country and available languages.
Storefront response of country and languages :
data => {__typename: QueryRoot, localization: {__typename: Localization, availableLanguages: [{__typename: Language, isoCode: EN, endonymName: English}, {__typename: Language, isoCode: ZH, endonymName: 繁體中文}], availableCountries: [{__typename: Country, isoCode: HK, name: Hong Kong SAR, availableLanguages: [{__typename: Language, isoCode: EN, endonymName: English}, {__typename: Language, isoCode: ZH, endonymName: 繁體中文}]}]}}
This is a the graphQL script we are using. The code is followed the solution from SDK board and storefront development doc. API version is 2022-10.
const String getNProductsQuery = r''' query ($n: Int, $sortKey: ProductSortKeys, $reverse: Boolean, $country: CountryCode, $language: LanguageCode) @inContext(country: $country, language: $language) { products(first: $n, sortKey: $sortKey, reverse: $reverse) { pageInfo { hasNextPage } edges { cursor node { options(first: 50) { id name values } variants(first: 250) { edges { node { id title image { altText id originalSrc } priceV2 { amount currencyCode } compareAtPriceV2 { amount currencyCode } weight weightUnit availableForSale sku requiresShipping quantityAvailable selectedOptions { name value } } } pageInfo { hasNextPage } } availableForSale collections(first: 250) { edges { node { description descriptionHtml id handle updatedAt title } } } createdAt description descriptionHtml handle id onlineStoreUrl productType publishedAt tags title updatedAt vendor images(first: 250) { edges { node { altText id originalSrc } } } } } } } ''';
Dose anyone can give me some solution about this issue ?
Solved! Go to the solution
This is an accepted solution.
Finally, the find out this issue is seems to be reflected by the storefront API version. Since the date we start on development, the latest version is 2022-10. Then the Shopify had a loads of versioning update.
Currently, We updated the version to 2023-04. The translation is working again. So, I think the all the developer should be keep the version update to date as possible as you can.
Hi @cyrus1127,
I haven't been able to replicate missing translations on a test store, but I did notice that you have two `isoCode: ZH` in your localizations data. Have you tested using the `ZH_CN` or `ZH_TW` Language Code values to see if those work?
If not, then I would recommend reaching out to support to have them take a look at the translations on your store and determine why they are not being returned by the API.
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Yes, of cause I had tested with `ZH_TW` and `ZH_CN`. The first time to test the @inContext statement, I hardcode the language in 'ZH_TW'. The result is positive. But after the first week, everything is abnormally return all in english(current default language is EN).
The case I had tested :
/// without country code :
@inContext(language: ZH) { ... }// first week dosen't work , get EN content
@inContext(language: ZH_TW) { ... } // first week work , and get the right translation
@inContext(language: ZH_CN) { ... }// first week dosen't work , same as ZH
/// with country code :
@inContext(country: HK, language: ZH) { ... }// first week dosen't work , get EN content
@inContext(country: HK, language: ZH_TW) { ... } // first week work , and get the right translation
@inContext(country: HK, language: ZH_CN) { ... }// first week dosen't work , same as ZH
Yes, of cause I had tested with `ZH_TW` and `ZH_CN`. The first time to test the @inContext statement, I hardcode the language in 'ZH_TW'. The result is positive. But after the first week, everything is abnormally return all in english(current default language is EN).
The case I had tested :
/// without country code :
@inContext(language: ZH) { ... }// first week dosen't work , get EN content
@inContext(language: ZH_TW) { ... } // first week work , and get the right translation
@inContext(language: ZH_CN) { ... }// first week dosen't work , same as ZH
/// with country code :
@inContext(country: HK, language: ZH) { ... }// first week dosen't work , get EN content
@inContext(country: HK, language: ZH_TW) { ... } // first week work , and get the right translation
@inContext(country: HK, language: ZH_CN) { ... }// first week dosen't work , same as ZH
This is an accepted solution.
Finally, the find out this issue is seems to be reflected by the storefront API version. Since the date we start on development, the latest version is 2022-10. Then the Shopify had a loads of versioning update.
Currently, We updated the version to 2023-04. The translation is working again. So, I think the all the developer should be keep the version update to date as possible as you can.