{"id":182,"date":"2024-04-19T14:15:25","date_gmt":"2024-04-19T17:15:25","guid":{"rendered":"https:\/\/kylekelly.com\/?p=182"},"modified":"2024-04-30T13:31:54","modified_gmt":"2024-04-30T16:31:54","slug":"wpml-translating-blocks-that-arent-translatable","status":"publish","type":"post","link":"https:\/\/kylekelly.com\/posts\/wpml-translating-blocks-that-arent-translatable\/","title":{"rendered":"WPML: Translating blocks that aren’t translatable"},"content":{"rendered":"\n

A follow up to yesterday’s post: Getwid-Megamenu WPML<\/a><\/p>\n\n\n\n

I ran into an issue that the Previous & Next buttons in my single-post template were not translatable in WPML.<\/p>\n\n\n\n

The first step was to take a look at the HTML for the block from the editor:<\/p>\n\n\n\n

<!-- wp:post-navigation-link {\"type\":\"previous\",\"label\":\"Previous Story\",\"arrow\":\"arrow\"} \/--><\/code><\/pre>\n\n\n\n

We can see that the text we want to translate is in the “label” field.<\/p>\n\n\n\n

In a wpml-config.xml file (in your theme), or in WPML->Settings->Custom XML Configuration you can set that a field in a blocks attributes is translatable. Here is how to do that for the block above:<\/p>\n\n\n\n

<wpml-config>\n  <gutenberg-blocks>\n    <gutenberg-block type=\"core\/post-navigation-link\" translate=\"1\">\n      <key name=\"label\" \/>\n    <\/gutenberg-block>\n  <\/gutenberg-blocks>\n<\/wpml-config><\/code><\/pre>\n\n\n\n

Save that, then send the template to translation again and it should<\/em> now be able to be translated.<\/p>\n","protected":false},"excerpt":{"rendered":"

A follow up to yesterday’s post: Getwid-Megamenu WPML I ran into an issue that the Previous & Next buttons in my single-post template were not translatable in WPML. The first step was to take a look at the HTML for the block from the editor: We can see that the text we want to translate […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[9,18],"_links":{"self":[{"href":"https:\/\/kylekelly.com\/wp-json\/wp\/v2\/posts\/182"}],"collection":[{"href":"https:\/\/kylekelly.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kylekelly.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kylekelly.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kylekelly.com\/wp-json\/wp\/v2\/comments?post=182"}],"version-history":[{"count":5,"href":"https:\/\/kylekelly.com\/wp-json\/wp\/v2\/posts\/182\/revisions"}],"predecessor-version":[{"id":198,"href":"https:\/\/kylekelly.com\/wp-json\/wp\/v2\/posts\/182\/revisions\/198"}],"wp:attachment":[{"href":"https:\/\/kylekelly.com\/wp-json\/wp\/v2\/media?parent=182"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kylekelly.com\/wp-json\/wp\/v2\/categories?post=182"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kylekelly.com\/wp-json\/wp\/v2\/tags?post=182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}