block_formats options not translated if using documented approach
- 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
- Set a
block_formatsoption 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;
- Set language to German
- Ensure that the
formatmenubar is present - 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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