Anchor to translationsRegistertranslations
translationsRegister
mutation
Requires access scope.
Creates or updates translations.
Anchor to Arguments
Arguments
- Anchor to resourceIdresource•
Id ID!required ID of the resource that is being translated.
- Anchor to translationstranslations•[Translation
Input!]! required Specifies the input fields for a translation.
Was this section helpful?
Anchor to TranslationsRegisterPayload returnsTranslationsRegisterPayload returns
- Anchor to translationstranslations•
The translations that were created or updated.
- Anchor to userErrorsuser•
Errors [TranslationUser non-nullError!]! The list of errors that occurred from executing the mutation.
Was this section helpful?
- Register a French product title
- Register a French product title specific to a market
- Register a product title in the shop default language specific to a market
- translationsRegister reference
Examples
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 mutation translationsRegister($resourceId: ID!, $translations: [TranslationInput!]!) {6 translationsRegister(resourceId: $resourceId, translations: $translations) {7 userErrors {8 message9 field10 }11 translations {12 key13 value14 }15 }16 }`,17 {18 variables: {19 "resourceId": "gid://shopify/Product/20995642",20 "translations": [21 {22 "locale": "fr",23 "key": "title",24 "value": "L'élément",25 "translatableContentDigest": "4e5b548d6d61f0006840aca106f7464a4b59e5a854317d5b57861b8423901bf6"26 }27 ]28 },29 },30);3132const data = await response.json();33
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/unstable/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();
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"
}
]
},
},
});
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)
Input variables
JSON1{2 "resourceId": "gid://shopify/Product/20995642",3 "translations": [4 {5 "locale": "fr",6 "key": "title",7 "value": "L'élément",8 "translatableContentDigest": "4e5b548d6d61f0006840aca106f7464a4b59e5a854317d5b57861b8423901bf6"9 }10 ]11}
Response
JSON1{2 "translationsRegister": {3 "userErrors": [],4 "translations": [5 {6 "key": "title",7 "value": "L'élément"8 }9 ]10 }11}