productPageTranslate
Creates a translation of a product page in another locale. The translation is a new product page with its own ID, linked to the source through localizedReferences. It's created as a draft; publish it with productPagePublish.
Any field you leave out of input is copied from the source, except its status and publish dates. Each locale can have one translation; translating into a locale that already has one returns an error, so use the update mutation on the translation's ID to change it.
Fails while a content release is selected (X-Pack-Release-Id). To read translated content, pass language and country to the @inContext directive; see Localization.
Arguments
- Name
sourceContentId- Type
- ID!
- Description
The ID of the product page to translate.
- Name
localeId- Type
- ID!
- Description
The ID of the locale to translate into, from your store's locales.
- Name
input- Type
- ProductPageInput!
- Description
An object with the translated values.
title:Stringhandle:StringsourceProductId:StringThe Shopify product GID.description:Stringseo:SEOInputsectionIds:[ID!]The sections for the translation, in order. Each section that already has a translation in this locale is swapped for it. If you leave this out, the translation uses the source's sections.template:StringThe title of the template to attach.templateId:IDThe ID of the template to attach.firstPublishedAt:DateTimefirstPublishedAtTimezone:StringsectionOverrides:JSONSection overrides for this content, as JSON.
Returns
- Name
ProductPage.*- Type
- ProductPage
- Description
Any requested field from the ProductPage object for the new translation.
Request
import { PackClient } from '@pack/client'
const packClient = new PackClient({
token: 'YOUR-PACK-SECRET-TOKEN'
});
const query = `
mutation ProductPageTranslate($sourceContentId: ID!, $localeId: ID!, $input: ProductPageInput!) {
productPageTranslate(sourceContentId: $sourceContentId, localeId: $localeId, input: $input) {
id
title
status
locale {
languageCode
countryCode
}
}
}
`;
const variables = {
sourceContentId: 'YOUR-SOURCE-ID',
localeId: 'YOUR-LOCALE-ID',
input: {
title: 'T-shirt classique'
}
};
const response = await packClient.fetch(query, { variables: variables });
console.log(response.data);
Response
{
"data": {
"productPageTranslate": {
"id": "YOUR-TRANSLATED-ID",
"title": "T-shirt classique",
"status": "draft",
"locale": {
"languageCode": "fr",
"countryCode": "CA"
}
}
}
}