Have your say in Community Polls: What was/is your greatest motivation to start your own business?
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.

How to get other languages in translatableResources in GraphQL API?

How to get other languages in translatableResources in GraphQL API?

SergioF_
Visitor
1 0 0
I'm working with translations in Shopify API. I have English set as the default language, but now I've also added Portuguese as a language and published it (I haven't added any translations though).
However, when I call the GraphQL translatableResources, it only returns the translatable content for English.
 

I'm using postman. This is my query

query getTranslatableResources {
  translatableResource(resourceId: "gid://shopify/Product/7276207800399") {
    resourceId
    translatableContent {
      key
      value
      translatableContentDigest: digest
      locale
    }
  }
}

And this is the translatableContent object I get in the response:

"translatableContent": [
                {
                    "key": "title",
                    "value": "Cartridge Medium Taper Gauge 10 Tight Liner 5 needles (More than 10 month validity)",
                    "translatableContentDigest": "a73b0b1ad55fc98ab46fb1d41dcb10f7877747c4dc8ed5798129cce398cf0f30",
                    "locale": "en"
                },
                {
                    "key": "body_html",
                    "value": "test",
                    "translatableContentDigest": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
                    "locale": "en"
                },
                {
                    "key": "handle",
                    "value": "needle-3",
                    "translatableContentDigest": "deff7e9e149736d4e3ab2e3a1e8268c2015a9a4f54f42b67224dbd0e0f73b91c",
                    "locale": "en"
                },
                {
                    "key": "product_type",
                    "value": "",
                    "translatableContentDigest": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
                    "locale": "en"
                }
            ]

As you can see, I have added and published Portuguese as a language.

 
SergioF__1-1709891017915.png

 

What am I missing?

Reply 1 (1)

ShopifyDevSup
Shopify Staff
1453 238 524

Hi @SergioF_ ,

 

Thanks for your post. To see the translations for an added language 'translations' needs to be added to the query with the specification of 'locale' and the desired language. Here's an example from the bottom of the dev docs reference page for the translatableResource mutation adapted to use the info you provided:

 

{
 translatableResource(resourceId: "gid://shopify/Product/7276207800399") {
   resourceId
   translations(locale: "pt") {
     key
     value
   }
 }
}

 

More info on working with translations with GraphQL can be found on this dev docs page:

https://shopify.dev/docs/apps/selling-strategies/markets/translate-content

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog