A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hello everyone and Shopify team!
I need some help with updating the content of the primary locale language for a store using the translationsRegister
mutation. I tried querying the field and content digest for the locale from the translatableResources
query. Then, I sent the field with an updated value to the translationsRegister
query.
However, I receive the following error:
{
"translationsRegister": {
"userErrors": [
{
"message": "Locale cannot be the same as the shop's primary locale",
"code": "INVALID_LOCALE_FOR_SHOP",
"field": [
"translations",
"0",
"locale"
]
}
],
"translations": []
}
}
Is this a bug, or is this a use case not supported by Shopify admin APIs on purpose? You can update the content/translation for the primary language through admin store settings, but not through the admin APIs? I would appreciate some guidance or additional resources to support this use case in my Shopify app. If it is not supported by Shopify, it would be helpful to know whether this will be worked on in the future (with an expected ETA) or not supported at all.
Additional details:
TranslatableResource:
query getTranslatableResources {
translatableResource(resourceId: "gid://shopify/OnlineStoreTheme/146647515454") {
resourceId
translatableContent {
key
value
translatableContentDigest: digest
locale
}
}
}
TranslationsRegister:
mutation translationsRegister($resourceId: ID!, $translations: [TranslationInput!]!) {
translationsRegister(resourceId: $resourceId, translations: $translations) {
userErrors {
message
code
field
}
translations {
key
value
}
}
}
Variables:
{
"resourceId": "gid://shopify/OnlineStoreTheme/themeId",
"translations": [
{
"locale": "en",
"key": "shopify.checkout.payment.title",
"value": "Example new title",
"translatableContentDigest": "digestfrompreviousquery"
}
]
}
Unfortunately, translationsRegister doesn't support translations for the Primary Locale of the Shop it only supports translations for other published languages. however, you could update the resource title value directly in the resource itself as a workaround. eg: for a Product body_html.
This is not really possible for the theme resource, which you need to be able to change, to adjust the strings for the checkout in the primary locale.
The "Translate & Adapt" app is able to do it, and I am wondering how.