Re: Gap in Translations API for Product Options?

Gap in Translations API for Product Options?

Shaibt
Shopify Partner
34 1 33

Using the Translations API docs the only translatable field for the type PRODUCT_OPTION

is name.

 

There is no option to set translations for the option's values.

 

When using a query such as this:

 

query ($productId: ID!, $locale: String! )  {
    product(id: $productId) {
      id
      handle
      title
      status
      onlineStoreUrl
      totalInventory
      hasOnlyDefaultVariant
      translations(locale: $locale) {
        key
        value
      }
      options(first: 3) {
        name
        values
        translations(locale: $locale) {
            key
            value
        }
      }
  }
}

 

 

results in:

 

"data": {
        "product": {
            "id": "gid://shopify/Product/...",
            "handle": "...",
            "title": "...",
            "status": "ACTIVE",
            "onlineStoreUrl": "...",
            "totalInventory": 187,
            "hasOnlyDefaultVariant": false,
            "translations": [
                {
                    "key": "body_html",
                    "value": "<p>C'est une Apple produit.</p>"
                },
                {
                    "key": "title",
                    "value": "Apple Cinematic 30\""
                }
            ],
            "options": [
                {
                    "name": "An Option",
                    "values": [
                        "Large",
                        "Medium",
                        "Small"
                    ],
                    "translations": [
                        {
                            "key": "name",
                            "value": "Translated Option"
                        }
                    ]
                },
                {
                    "name": "Another Option",
                    "values": [
                        "Yellow",
                        "Green",
                        "Blue",
                        "Red"
                    ],
                    "translations": [
                        {
                            "key": "name",
                            "value": "ANother translated option"
                        }
                    ]
                },
                {
                    "name": "And again",
                    "values": [
                        "Checkbox 4",
                        "Checkbox 3",
                        "Checkbox 2",
                        "Checkbox 1"
                    ],
                    "translations": [
                        {
                            "key": "name",
                            "value": "And again translated"
                        }
                    ]
                }
            ]
        }
    }

 

 

The values themselves are not translated and there is no possibility to use this query to display the possible option values in any language other than the default (non-translated) language.

 

The PRODUCT_VARIANT translatable resource does allow translations of each variants value for product options named option1, option2, option3 but I don't understand how this is helpful:

  1. How do I map option1, option2, option3 to the actual product options?
  2. Even if possible, why would I need to query all product variants to get translated option values - these should come in the Product object just like the original (default) values for each option.

Anyone work around this somehow? IMO, Makes the Admin API unusable for presenting product option values in a multi-language setting.

 

 

Replies 8 (8)

Francois_paris
Shopify Partner
10 0 2

I have the same problem.

Did you manage to translate a specific product options names/values using GraphQL?

I cannot find any way to translate those resources

Kalen_Jordan
Shopify Partner
758 34 135

Also running into this issue right now. End up finding a solution?

Francois_paris
Shopify Partner
10 0 2

Hi!

here is my post, which explain how I did it:

 

 

How to translate product variants options "name" and "value" using GraphQL?
https://community.shopify.com/c/graphql-basics-and/how-to-translate-product-variants-options-quot-na...

Kalen_Jordan
Shopify Partner
758 34 135

Thanks!

Francois_paris
Shopify Partner
10 0 2

Actually, I managed to translate the product option "name" (ex: "color") and I thought I would translate the product option "values" the same way, but it does not work. I can't find any way to translate the option values (in ex. "red", "green" etc.).

If I use the ProductVariant object to translate this option value, it does not work.

When I query the Product object I can get the options values, but then those values are not within the TranslatableResource query…

I found this object but it's only in the unstable API version: https://shopify.dev/docs/api/admin-graphql/unstable/objects/ProductOptionValue

 

Did you find a way to translate product options values?

Kalen_Jordan
Shopify Partner
758 34 135

Yeah I did it by grabbing the translatable content on the variant. That gives you a digest you can use to edit them.

 

Screenshot 2023-12-27 at 3.10.33 PM.png

Francois_paris
Shopify Partner
10 0 2

Hi Kalen

Yes, I thought I would do the same, but the weird thing is: Whet I get the translatable resource from the productVariant, I get the necessary data (key, hash digest, etc.) but when I translate those data, it just duplicates the translations.

As a result, on my product page, My product variants options are duplicated (which is weird) and it completely mess up my product page in other languages.

You don't have this problem on your side?

 

Maybe I have this problem because several of my products variants have the same options value, in exemple {Red, S}, {Red, M}, {Red, L}, etc. It does translate each of those "Red" and as a result, those are duplicated in the "Shopify Translate & Adapt" app, and on the product page on the front-end side.

 

In my opinion, Product->Options->values should be the translated element, but Shopify does not allow it, as this is in the query but not in the translatable resources.

Kalen_Jordan
Shopify Partner
758 34 135

I actually haven't looked at the frontend yet - I'm only working on populating the backend. Also the products I've tested with only have one option on them it seems (size). I agree the option values themselves should be the translated element.