Anchor to section titled 'undefined'

translationsRegister
mutation

Requires write_translations access scope.

Creates or updates translations.


Anchor to resourceId
resourceId
required

ID of the resource that is being translated.

Specifies the input fields for a translation.


Was this section helpful?

The translations that were created or updated.

The list of errors that occurred from executing the mutation.


Was this section helpful?

Examples

Hide code
DescriptionCopy
mutation translationsRegister($resourceId: ID!, $translations: [TranslationInput!]!) {
  translationsRegister(resourceId: $resourceId, translations: $translations) {
    userErrors {
      message
      field
    }
    translations {
      key
      value
    }
  }
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation translationsRegister($resourceId: ID!, $translations: [TranslationInput!]!) { translationsRegister(resourceId: $resourceId, translations: $translations) { userErrors { message field } translations { key value } } }",
 "variables": {
    "resourceId": "gid://shopify/Product/20995642",
    "translations": [
      {
        "locale": "fr",
        "key": "title",
        "value": "L'\''élément",
        "translatableContentDigest": "4e5b548d6d61f0006840aca106f7464a4b59e5a854317d5b57861b8423901bf6"
      }
    ]
  }
}'
const { admin } = await authenticate.admin(request);

const response = await admin.graphql(
  `#graphql
  mutation translationsRegister($resourceId: ID!, $translations: [TranslationInput!]!) {
    translationsRegister(resourceId: $resourceId, translations: $translations) {
      userErrors {
        message
        field
      }
      translations {
        key
        value
      }
    }
  }`,
  {
    variables: {
      "resourceId": "gid://shopify/Product/20995642",
      "translations": [
        {
          "locale": "fr",
          "key": "title",
          "value": "L'élément",
          "translatableContentDigest": "4e5b548d6d61f0006840aca106f7464a4b59e5a854317d5b57861b8423901bf6"
        }
      ]
    },
  },
);

const data = await response.json();
session = ShopifyAPI::Auth::Session.new(
  shop: "your-development-store.myshopify.com",
  access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
  session: session
)

query = <<~QUERY
  mutation translationsRegister($resourceId: ID!, $translations: [TranslationInput!]!) {
    translationsRegister(resourceId: $resourceId, translations: $translations) {
      userErrors {
        message
        field
      }
      translations {
        key
        value
      }
    }
  }
QUERY

variables = {
  "resourceId": "gid://shopify/Product/20995642",
  "translations": [{"locale"=>"fr", "key"=>"title", "value"=>"L'élément", "translatableContentDigest"=>"4e5b548d6d61f0006840aca106f7464a4b59e5a854317d5b57861b8423901bf6"}]
}

response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session});
const data = await client.query({
  data: {
    "query": `mutation translationsRegister($resourceId: ID!, $translations: [TranslationInput!]!) {
      translationsRegister(resourceId: $resourceId, translations: $translations) {
        userErrors {
          message
          field
        }
        translations {
          key
          value
        }
      }
    }`,
    "variables": {
      "resourceId": "gid://shopify/Product/20995642",
      "translations": [
        {
          "locale": "fr",
          "key": "title",
          "value": "L'élément",
          "translatableContentDigest": "4e5b548d6d61f0006840aca106f7464a4b59e5a854317d5b57861b8423901bf6"
        }
      ]
    },
  },
});
use Shopify\Clients\Graphql;

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$query = <<<QUERY
  mutation translationsRegister($resourceId: ID!, $translations: [TranslationInput!]!) {
    translationsRegister(resourceId: $resourceId, translations: $translations) {
      userErrors {
        message
        field
      }
      translations {
        key
        value
      }
    }
  }
QUERY;

$variables = [
  "resourceId" => "gid://shopify/Product/20995642",
  "translations" => [{"locale"=>"fr", "key"=>"title", "value"=>"L'élément", "translatableContentDigest"=>"4e5b548d6d61f0006840aca106f7464a4b59e5a854317d5b57861b8423901bf6"}],
];

$response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{
  "resourceId": "gid://shopify/Product/20995642",
  "translations": [
    {
      "locale": "fr",
      "key": "title",
      "value": "L'élément",
      "translatableContentDigest": "4e5b548d6d61f0006840aca106f7464a4b59e5a854317d5b57861b8423901bf6"
    }
  ]
}
Hide code
Response
JSON
{
  "translationsRegister": {
    "userErrors": [],
    "translations": [
      {
        "key": "title",
        "value": "L'élément"
      }
    ]
  }
}