Skip to content

Commit d0484c4

Browse files
committed
Merge remote-tracking branch 'origin/main' into next
2 parents 4ae82a1 + 059fc2c commit d0484c4

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,21 @@ return reduceFunction(
276276
)
277277
```
278278

279-
The translate function receives the format of the text as `plain`, `markdown` or `html`. If your translation provider supports only html, but no markdown, you can use the `format` service to change the format before translating to `html` and afterwards back to `markdown`:
279+
The translate function receives the format of the text as `plain`, `markdown`, `html` or `jsonb` (Blocks Content Type). If your translation provider supports only html, but no markdown, you can use the `format` service to change the format before translating to `html` and afterwards back to `markdown`. Similarly you can convert `jsonb` to `html`:
280280

281281
```js
282-
const { markdownToHtml, htmlToMarkdown } = strapi.service(
282+
const { markdownToHtml, htmlToMarkdown, blocksToHtml, htmlToBlocks } = strapi.service(
283283
'plugin::translate.format'
284284
)
285285

286286
if (format === 'markdown') {
287287
return htmlToMarkdown(providerClient.translateTexts(markdownToHtml(text)))
288288
}
289+
290+
if (format === 'jsonb') {
291+
return htmlToBlocks(providerClient.translateTexts(blocksToHtml(text)))
292+
}
293+
289294
return providerClient.translateTexts(texts)
290295
```
291296

plugin/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,21 @@ return reduceFunction(
276276
)
277277
```
278278

279-
The translate function receives the format of the text as `plain`, `markdown` or `html`. If your translation provider supports only html, but no markdown, you can use the `format` service to change the format before translating to `html` and afterwards back to `markdown`:
279+
The translate function receives the format of the text as `plain`, `markdown`, `html` or `jsonb` (Blocks Content Type). If your translation provider supports only html, but no markdown, you can use the `format` service to change the format before translating to `html` and afterwards back to `markdown`. Similarly you can convert `jsonb` to `html`:
280280

281281
```js
282-
const { markdownToHtml, htmlToMarkdown } = strapi.service(
282+
const { markdownToHtml, htmlToMarkdown, blocksToHtml, htmlToBlocks } = strapi.service(
283283
'plugin::translate.format'
284284
)
285285

286286
if (format === 'markdown') {
287287
return htmlToMarkdown(providerClient.translateTexts(markdownToHtml(text)))
288288
}
289+
290+
if (format === 'jsonb') {
291+
return htmlToBlocks(providerClient.translateTexts(blocksToHtml(text)))
292+
}
293+
289294
return providerClient.translateTexts(texts)
290295
```
291296

0 commit comments

Comments
 (0)