A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I'm trying to set up a bilingual store passing information from an in-house database to an online store. I have the store set up with the Translate & Adapt App and can retrieve product information using the graphql api. I'm pretty sure translating the regular content (title, description etc.) won't be an issue but I'm struggling with the metafield data. It isn't clear whether it's possible to register a language mutation for a multi-line text custom metafield. It would be great to know whether or not its possible, and if it is, where to find the post format. I can retrieve the id of the metafield and its english content but translation seems to require a digest value which a metafield doesn't have. Any help would be greatly appreciated.
Hi @randomstream 👋
Metafields are a supported `TranslatableResourceType` and the associated `digest` fields can be queried using `translatableResources`:
{
translatableResources(first: 5, resourceType: METAFIELD) {
nodes {
resourceId
translatableContent {
key
value
digest
locale
}
}
}
}
We also have a great guide here that outlines how to interact with the APIs facing translatable resources.
Hope that helps!
Umiko | API Support @ Shopify
- Was my reply helpful? Click Like to let me 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
Hi @Umiko . Thank you for your reply. I can successfully use translatableResources to retrieve product metafields but it doesn't allow me to request a specific product. In order to do that I need to use translatableResource, which doesn't then give me the digest or locale. I can retrieve the key and think I can generate the digest but when I try to set the translation I get the error that the key retrieved using translatableResource is not a translatable field.
this is the response from translatableResource:
{"data":{"product":{"metafield":{"value":"Protein: 2.2g","id":"gid:\/\/shopify\/Metafield\/XXX","key":"nutrition"}}},"extensions":{"cost":{"requestedQueryCost":2,"actualQueryCost":2,"throttleStatus":{"maximumAvailable":1000.0,"currentlyAvailable":998,"restoreRate":50.0}}}}
This is the curl json I'm sending
{ "query": "mutation CreateTranslation($id: ID!, $translations: [TranslationInput!]!) { translationsRegister(resourceId: $id, translations: $translations) { userErrors {message field} translations {locale key value} } }", "variables": { "id": "
gid://shopify/Product/XXXX", "translations": [ { "key": "nutrition", "value": "タンパク質2.2g", "locale": "ja", "translatableContentDigest": XXX" } ] } }
I've tried setting the gid as both the product gid and the metafield gid but both returned an error that the key was not a translatable field. Are you able to see where I'm going wrong?
I've finally succeeded so am making a note here for anyone else struggling. I used translatableResource with the product ID to get the metafield ID, then created the translatableContentDigest manually, then sent this json: