Back to Content Management API

siteSettingsTranslate

Creates a translation of a site settings in another locale. The translation is a new site settings with its own ID, linked to the source through localizedReferences. It's created as a draft; publish it with siteSettingsPublish.

Any field you leave out of input is copied from the source, except its status and publish dates. If you leave out input, everything is copied. 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 site settings to translate.

  • Name
    localeId
    Type
    ID
    Description

    The ID of the locale to translate into, from your store's locales. Required in practice: the translation can't be created without a target locale.

  • Name
    input
    Type
    SiteSettingsUpdateInput
    Description

    An object with the translated values.

    • settings: JSON! The translated settings, as JSON.
    • seo: JSON
    • favicon: String
    • changedSettingsPaths: [String!] Not used when translating.

Returns

  • Name
    SiteSettings.*
    Type
    SiteSettings!
    Description

    Any requested field from the SiteSettings object for the new translation.

Request

import { PackClient } from '@pack/client'
const packClient = new PackClient({
  token: 'YOUR-PACK-SECRET-TOKEN'
});

const query = `
  mutation SiteSettingsTranslate($sourceContentId: ID!, $localeId: ID, $input: SiteSettingsUpdateInput) {
    siteSettingsTranslate(sourceContentId: $sourceContentId, localeId: $localeId, input: $input) {
      id
      status
      locale {
        languageCode
        countryCode
      }
    }
  }
`;

const variables = {
  sourceContentId: 'YOUR-SITE-SETTINGS-ID',
  localeId: 'YOUR-LOCALE-ID',
  input: {
    settings: { header: { announcementBar: { text: 'Livraison gratuite' } } }
  }
};
const response = await packClient.fetch(query, { variables: variables });
console.log(response.data);

Response

{
    "data": {
        "siteSettingsTranslate": {
            "id": "YOUR-TRANSLATED-ID",
            "status": "draft",
            "locale": {
                "languageCode": "fr",
                "countryCode": "CA"
            }
        }
    }
}

Was this page helpful?