Translating Product Options

Hi!

I’m trying to translate my products to support Swedish. I have managed to get Title, Description, and Option names translated so far using GraphQL. However, I’m having issues with the Option values.

These are the mutations I’ve been successfully using so far:

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

Would it be possible to get Option values translated using either of these, and if so how would I go about it? If that’s not possible, are there any other mutations or methods that could get it done?

Any help is much appreciated!
Thanks

Hi,

I believe you should be able to use the same mutation to translate option values - but you’d need to get the option values IDs first, via a query like this:

query GetProductOptions {
  product(id: "gid://shopify/Product/123456789") { # Replace with your product ID
    options {
      id
      name
      optionValues {
        id
        name
      }
    }
  }
}

That worked perfectly! Thank you very much.

I will be doing this for a large number of products, so is there any bulk mutation I could use for getting the option value IDs? Or perhaps some other approach that would make this easier for me?

1 Like

Glad it worked!

It could be possible to use a bulk query to get products option IDs- this example shows a bulk query to get product title, so you should be able to add fields for optionValues, without hitting the max of two nested levels.