Builder content link
https://builder.io/content/d621971c72094ba68a96cdbb9dd1d28d
Builder public api key
64dd5478e25746bf9db3b6c0319905f6
What are you trying to accomplish
When the store is loaded in a non-default language, the Shopify strings populated by Builder should be the translated equivalent in Shopify’s database.
Screenshots or video link
Code stack you are integrating Builder with
react
Reproducible code example
Builder’s default code for fetching product information, which fails to get the translated strings:
function updateProduct() {
var _a;
const productId = getProductId();
if (state.productInfo && !productId) {
setDefaultVariant();
return;
}
if (productId) {
state.loading = true;
const shopify = window.Shopify || {};
const activeCurrency = ((_a = shopify.currency) === null || _a === void 0 ? void 0 : _a.active) || 'USD';
return fetch(`https://cdn.builder.io/api/v1/shopify/product-box-data?apiKey=${state.apiKey || context.apiKey || builder.apiKey}&productId=${productId}¤cyIsoCode=${activeCurrency}`)
.then(res => res.json())
.then(data => {
const { products } = data;
if (products && products.length) {
const productInfo = products[0];
state.productInfo = productInfo;
// console.log('gweesh?', {productInfo}); //debug
setDefaultVariant();
}
state.loading = false;
})
.catch(err => {
console.error('Error fetching Shopify product', err);
state.loading = false;
});
}
else {
state.productInfo = null;
}
}
updateProduct();
My own liquid code that pulls in translated product metadata:
let finePrint = "{{ product.metafields.store.fine_print | newline_to_br | strip_newlines | default: fallbackText }}";