Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ module.exports = {
},
// Which field types are translated (default string, text, richtext, components and dynamiczones)
// Either string or object with type and format
// Possible formats: plain, markdown, html (default plain)
// Possible formats: plain, markdown, html, jsonb (default plain)
translatedFieldTypes: [
'string',
{ type: 'blocks', format: 'jsonb' },
{ type: 'text', format: 'plain' },
{ type: 'richtext', format: 'markdown' },
'component',
Expand Down
8 changes: 8 additions & 0 deletions playground/config/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ module.exports = ({ env }) => ({
config: {
provider: env('TRANSLATE_PROVIDER', 'deepl'),
providerOptions: {},
translatedFieldTypes: [
'string',
{ type: 'blocks', format: 'jsonb' },
{ type: 'text', format: 'plain' },
{ type: 'richtext', format: 'markdown' },
'component',
'dynamiczone',
],
regenerateUids: true,
},
},
Expand Down
2 changes: 1 addition & 1 deletion playground/cypress/e2e/batch-update.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('batch update', () => {
// Login and translate first category
cy.login()
cy.visit(
'/admin/content-manager/collectionType/api::category.category/create?plugins[i18n][locale]=de&plugins[i18n][relatedEntityId]=1'
'/admin/content-manager/collection-types/api::category.category/create?plugins[i18n][locale]=de&plugins[i18n][relatedEntityId]=1'
)
cy.get('#name').type('translation')
cy.get('button[type=submit]').focus()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"kind": "collectionType",
"collectionName": "blocks_articles",
"info": {
"singularName": "blocks-article",
"pluralName": "blocks-articles",
"displayName": "BlocksArticle",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {
"i18n": {
"localized": true
}
},
"attributes": {
"Title": {
"type": "string",
"pluginOptions": {
"i18n": {
"localized": true
},
"translate": {
"translate": "translate"
}
}
},
"Content": {
"type": "blocks",
"pluginOptions": {
"i18n": {
"localized": true
},
"translate": {
"translate": "translate"
}
}
},
"writer": {
"type": "relation",
"relation": "oneToOne",
"target": "api::writer.writer",
"pluginOptions": {
"translate": {
"translate": "translate"
}
}
},
"category": {
"type": "relation",
"relation": "oneToOne",
"target": "api::category.category",
"pluginOptions": {
"translate": {
"translate": "translate"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

/**
* blocks-article controller
*/

const { createCoreController } = require('@strapi/strapi').factories;

module.exports = createCoreController('api::blocks-article.blocks-article');
9 changes: 9 additions & 0 deletions playground/src/api/blocks-article/routes/blocks-article.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

/**
* blocks-article router
*/

const { createCoreRouter } = require('@strapi/strapi').factories;

module.exports = createCoreRouter('api::blocks-article.blocks-article');
9 changes: 9 additions & 0 deletions playground/src/api/blocks-article/services/blocks-article.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

/**
* blocks-article service
*/

const { createCoreService } = require('@strapi/strapi').factories;

module.exports = createCoreService('api::blocks-article.blocks-article');
3 changes: 2 additions & 1 deletion plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ module.exports = {
},
// Which field types are translated (default string, text, richtext, components and dynamiczones)
// Either string or object with type and format
// Possible formats: plain, markdown, html (default plain)
// Possible formats: plain, markdown, html, jsonb (default plain)
translatedFieldTypes: [
'string',
{ type: 'blocks', format: 'jsonb' },
{ type: 'text', format: 'plain' },
{ type: 'richtext', format: 'markdown' },
'component',
Expand Down
1 change: 1 addition & 0 deletions plugin/admin/src/utils/translatableFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const TRANSLATABLE_FIELDS = [
'string',
'text',
'relation',
'blocks',
]

export default TRANSLATABLE_FIELDS
2 changes: 2 additions & 0 deletions plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
"dependencies": {
"@strapi/helper-plugin": "^4.15.0",
"axios": "^1.7.4",
"blocks-html-renderer": "^1.0.5",
"bottleneck": "^2.19.5",
"cache-manager": "^6.1.0",
"jsdom": "^25.0.0",
"showdown": "^2.1.0"
},
Expand Down
2 changes: 1 addition & 1 deletion plugin/server/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = {
}
if (
field.format &&
!['plain', 'markdown', 'html'].includes(field.format)
!['plain', 'markdown', 'html', 'jsonb'].includes(field.format)
) {
throw new Error(
`unhandled format ${field.format} for translated field ${field.type}`
Expand Down
Loading