Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

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.

 

Joda_Stoesser
Shopify Partner
24 0 6

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.

Building Club of Merchants -- the merchant-only community right in your Shopify admin dashboard

CTO @ coders.win for Shopify app development and consulting | All our apps
Please let me know if my reply is helpful by giving it a Like or marking it as the Solution!