translatableContent is an empty array

translatableContent is an empty array

redochkaya
Shopify Partner
20 0 1

TranslatableContent returned by Shopify is an empty array, which means no digest. No digest means no translation possible. Some other resources (including product option values) in the shop have translatable just fine.

 

Why is the translatableContent empty and how to get around this? 

 

query {
  translatableResourcesByIds(first: 10, resourceIds: ["gid://shopify/ProductOptionValue/5881291145563"]) {
    edges {
      node {
        resourceId
        translatableContent {
          key
          value
          digest
          locale
        }
      }
    }
  }
}

output:

{
    "data": {
        "translatableResourcesByIds": {
            "edges": [
                {
                    "node": {
                        "resourceId": "gid://shopify/ProductOptionValue/5881291145563",
                        "translatableContent": []
                    }
                }
            ]
        }
    },
}

of course this product option value exists and is returned when querying it by product id:

{
   "id": "gid://shopify/ProductOptionValue/5881291145563",
   "name": "M",
   "translations": []
}

Moreover, i tried to create the digest myself, even if i was skeptical if this is going to work (I was right), so I hashed the original content using sha256 as:

import crypto from 'crypto';

const hash = crypto.createHash("sha256").update(contentInDefaultLocale).digest("hex");

Then doing this mutation

mutation translationsRegister($resourceId: ID!, $translations: [TranslationInput!]!) {
          translationsRegister(resourceId: $resourceId, translations: $translations) {
              userErrors {
                  message
                  field
              }
              translations {
                  key
                  value
                  locale
              }
          }
      }

#data:

[{
gid : "gid://shopify/ProductOptionValue/5881291145563",
translations: [{
key : "name",
locale : "ro",
value : contentInDefaultLocale,
translatableContentDigest: hash,
}]
}]

i get this error:

[
  {
    message: 'Key name is not a valid translatable field',
    field: [ 'translations', '0', 'key' ]
  }
]

"name" should be a valid key in this case 🥲

Reply 1 (1)

redochkaya
Shopify Partner
20 0 1

Dear shopify team, any help with this?