Skip to content

Register translations ​

Last updated View as Markdown

Endpoint: https://api.youcan.shop/translations/{type}/{id}

Method: PUT

Required Scopes ​

  • edit-languages

Notes ​

  • Send the key and digest of each translation from the content of Get translations.
  • When a digest does not match the current text in the default language, nothing is saved and you get a 422. Read the item again and translate the new text.
  • Keys that you leave out keep their translation.
  • Texts of the theme_ types are validated like in the theme editor.
  • You get the item as in Get translations.

Parameters ​

Param NameParam TypeDescriptionRequired
typestringA translatable typeYes
idstringThe id of an item from the listingYes
localestringThe locale of a language from the listingYes
translationsarrayThe translations to saveYes
translations.*.keystringA key from contentYes
translations.*.valuestringThe translated textYes
translations.*.digeststringThe digest of the key from contentYes

Request ​

json
{
  "locale": "fr",
  "translations": [
    {
      "key": "product:0b6f1e1e-2f8e-4d7f-9a7d-3f8d3c2a1b00:description",
      "value": "<p>Chêne massif.</p>",
      "digest": "9d86477bf6bf82bb584f0b869ce2da86a7473ff2896a6b0a13c65ea69888cd12"
    }
  ]
}

Response ​

[422] Unprocessable entity, for a stale digest

json
{
  "status": 0,
  "detail": "The key is unknown or its source text changed. Read the resource again.",
  "meta": {
    "fields": {
      "translations.0.digest": ["The key is unknown or its source text changed. Read the resource again."]
    }
  }
}