Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] translate rich text blocks #402

Open
wants to merge 7 commits into
base: next
Choose a base branch
from

Conversation

sargreal
Copy link
Member

@sargreal sargreal commented Mar 1, 2024

This adds experimental support for translating the blocks editor (fixes #401). The current implementation is very rudimentary.

Things to consider before merging:

  • How to handle images better? The current way of creating a cache does not delete any images and may become a memory leak in large applications. But it is not clear when the cache may be deleted
  • How to handle code better? In the current state, DeepL may just translate the code and in the process also remove any line breaks.
  • Is it worth launching this feature in an experimental state, since we currently do not have the resources to fix bugs?

@sargreal sargreal requested a review from layaxx March 1, 2024 22:12
@sargreal sargreal linked an issue Mar 1, 2024 that may be closed by this pull request
Copy link

codecov bot commented Mar 1, 2024

Codecov Report

Attention: Patch coverage is 65.47619% with 29 lines in your changes are missing coverage. Please review.

Project coverage is 47.77%. Comparing base (0823a66) to head (3cb37ca).

Files Patch % Lines
plugin/server/services/format.js 68.57% 9 Missing and 13 partials ⚠️
providers/deepl/lib/index.js 50.00% 2 Missing and 2 partials ⚠️
providers/libretranslate/lib/index.js 50.00% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #402      +/-   ##
==========================================
+ Coverage   45.95%   47.77%   +1.81%     
==========================================
  Files          47       47              
  Lines         866      942      +76     
  Branches      187      211      +24     
==========================================
+ Hits          398      450      +52     
- Misses        310      322      +12     
- Partials      158      170      +12     
Flag Coverage Δ
unittests 47.77% <65.47%> (+1.81%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@layaxx layaxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should merge this into main right now. At most as an opt-in via a next release or something like that.
I agree that the handling of code (both blocks and inline) is not great, not sure what to do here. Same with the clearing of the img cache

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
plugin/README.md Outdated
translatedFieldTypes: [
'string',
{ type: 'block', format: 'jsonb' },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again:
is it block or blocks?
cf. playground/config/plugins.js and root-level README

plugin/server/services/format.js Outdated Show resolved Hide resolved
textArray = formatService.markdownToHtml(textArray)
let input = text
if (format === 'jsonb') {
input = formatService.blockToHtml(input)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the inverse conversion back to blocks format is missing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

translation of blocks-article type via libretranslate fails, not sure if this is the (only) reason

@bieblebrox
Copy link

Is there any progress on this? Would be a very useful feature to have.

@sargreal sargreal force-pushed the 401-feature-translate-rich-text-blocks branch from 3cb37ca to def1f32 Compare August 22, 2024 12:30
@sargreal sargreal changed the base branch from main to next August 23, 2024 06:38
@sargreal
Copy link
Member Author

I don't think we should merge this into main right now. At most as an opt-in via a next release or something like that. I agree that the handling of code (both blocks and inline) is not great, not sure what to do here. Same with the clearing of the img cache

I actually realised that code is currently handled the same with markdown and other html stuff. I believe that this should be made into a separate "known" bug for now.

@sargreal sargreal self-assigned this Aug 23, 2024
@sargreal sargreal modified the milestones: v2.0, v1.3 Aug 23, 2024
@sargreal sargreal force-pushed the 401-feature-translate-rich-text-blocks branch from 8bcc8be to 083804e Compare October 2, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

[FEATURE]: Translate Rich Text Blocks
3 participants