Skip to content

Commit d1f299d

Browse files
committed
doc: update provider info for jsonb
1 parent 1831871 commit d1f299d

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
@@ -263,16 +263,21 @@ return reduceFunction(
263263
)
264264
```
265265

266-
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`:
266+
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`:
267267

268268
```js
269-
const { markdownToHtml, htmlToMarkdown } = strapi.service(
269+
const { markdownToHtml, htmlToMarkdown, blocksToHtml, htmlToBlocks } = strapi.service(
270270
'plugin::translate.format'
271271
)
272272

273273
if (format === 'markdown') {
274274
return htmlToMarkdown(providerClient.translateTexts(markdownToHtml(text)))
275275
}
276+
277+
if (format === 'jsonb') {
278+
return htmlToBlocks(providerClient.translateTexts(blocksToHtml(text)))
279+
}
280+
276281
return providerClient.translateTexts(texts)
277282
```
278283

plugin/README.md

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

278-
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`:
278+
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`:
279279

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

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

0 commit comments

Comments
 (0)