Using Translationsregister mutation to update default locale translation

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

 

 

Replies 2 (2)

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.

 

SimJoSt
Shopify Partner
2 0 0

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.

Joda Stößer
Co-Founder coders.fail / coders.win for Shopify app development and consulting
DevOps, project management, architecture, and communication