Using Translationsregister mutation to update default locale translation

yasirnadeem
Shopify Partner
1 0 1

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"
        }
    ]
}

 

 

Reply 1 (1)

Trehana1
Shopify Partner
1 0 0

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.