React-Shopify翻译|如何从Shopify获得第二语言的产品

问题描述

我正在尝试从Shopify商店获取第二语言的产品。

Storefront API声明HTTP请求标头必须包含Accept-Language:de,就我而言(在React中),设置应如下所示: https://shopify.dev/tutorials/manage-app-translations-with-admin-api#storefront-api-translation-header

const clientWithTranslatedContent = Client.buildClient({
  domain: 'your-shop-name.myshopify.com',storefrontAccesstoken: 'your-storefront-access-token',language: 'de' // Accept-Language
});

如何工作,您可以在这里找到: https://github.com/Shopify/js-buy-sdk/blob/update-language-setting/src/client.js

我正在使用Shopify Webhook API版本2020-07(最新)。在gatsbyjs/gatsby#24173(注释)中,我找到了以下信息:在2020-04版中,Accept-Language标头支持翻译,但在我的情况下不起作用。

在构建应用程序时,我总是收到带有认翻译(EN)的商品。

解决方法

该问题是由在gatsby-node.js中生成页面的“ gatsby-source-shopify”插件引起的。它没有考虑HTTP请求标头中的Accept-Language。为了解决该问题,我的团队完成了此插件的安装。

以下是链接: https://github.com/alex-borodin-vtlabs/gatsby-source-shopify-translated

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...