tinymce / tinymce/tinymce

block_formats options not translated if using documented approach

Open Beginner friendly
#9,598 3 comments 1 reaction 0 assignees View on GitHub

@andrewnicols is already working on this.

Since Apr 29, 2024.

  • #9599 by @andrewnicols — open
status:stale
Dominant language
TypeScript
Stars
16.3k
Forks
2.3k
PR merge metrics
No merged PRs in 30d

Description

📝 Provide detailed reproduction steps (if any)

https://fiddle.tiny.cloud/Fug3lEC28d/0

  1. Set a block_formats option of (exact copy from docs):
Paragraph=p; Heading 1=h1; Heading 2=h2; Heading 3=h3; Heading 4=h4; Heading 5=h5; Heading 6=h6;
  1. Set language to German
  2. Ensure that the format menubar is present
  3. Open the Format menu -> Blocks
✔️ Expected result

All headings translated

❌ Actual result

Only paragraph is translated. Others are not

❓ Possible solution

I believe the following patch will solve the issue:

diff --git a/modules/tinymce/src/themes/silver/main/ts/ui/core/complex/SelectDatasets.ts b/modules/tinymce/src/themes/silver/main/ts/ui/core/complex/SelectDatasets.ts
index 01de005aa2..39a7892112 100644
--- a/modules/tinymce/src/themes/silver/main/ts/ui/core/complex/SelectDatasets.ts
+++ b/modules/tinymce/src/themes/silver/main/ts/ui/core/complex/SelectDatasets.ts
@@ -26,7 +26,7 @@ const process = (rawFormats: string[]): BasicSelectItem[] => Arr.map(rawFormats,
   // Allow text=value block formats
   const values = item.split('=');
   if (values.length > 1) {
-    title = values[0];
+    title = values[0].trim();
     format = values[1];
   }
 

I haven't worked out where to write a unit test for this but happy to provide one.

📃 Other details

  • Browser: Any
  • OS: Any.
  • First affected version: Unsure
  • Worked in version: Unsure

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in modules/tinymce/src/themes/silver/main/ts/ui/core/complex/SelectDatasets.ts and reproduce the issue with the linked TinyMCE fiddle using the documented block_formats value and German language. Verify how block-format labels are parsed and add regression coverage wherever the existing unit tests for this entry point reside. Done means all headings in the Format > Blocks menu are translated, not only Paragraph.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, localization
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.