Hat tip to @jhodgdon for finding this.
Problem/Motivation
The Editor
config entity cannot be translated because it does not have a dedicated edit form. Instead the editor settings are attached to the edit form of the TextFormat
config entity.
Because editor settings do not have any translatable settings in core this is marked minor and also not tagged with sprint. However, because editor settings support third_party_settings
contrib modules could add translatable values there and expect to be able to translate them with the Config Translation module. A use-case would be being able to edit button labels (or alt
tags, or title
tags).
Proposed resolution
Add the appropriate editor config object to the text format's config translation mapper.
Remaining tasks
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#43 | interdiff_40-43.txt | 901 bytes | shubham.prakash |
#43 | 2571371-43.patch | 5.92 KB | shubham.prakash |
#40 | interdiff_38-40.txt | 1.27 KB | shubham.prakash |
#40 | 2571371-40.patch | 5.84 KB | shubham.prakash |
#38 | interdiff_36-38.txt | 1.14 KB | shubham.prakash |
Comments
Comment #2
Wim LeersI'm not quite sure what
means.Also, there actually are translatable things even without third-party settings:
/admin/config/content/formats/manage/basic_html
blockquote.famous|Famous quote
Now
is a config value that you actually want to translate.Assigning to @Gábor Hojtsy for feedback.
Comment #3
Gábor Hojtsy#2546212: Entity view/form mode formatter/widget settings have no translation UI is a similar problem. Basically translation mappers in config translation map a set of config names to a route. So it can add a translate tab and several other routes to allow looking at translation status, translating the configs and deleting translations. So I think editor configs are edited on text format config pages, so you would need to alter the mapper for text formats to also have the editor entity. Again all the things that #2546212: Entity view/form mode formatter/widget settings have no translation UI is postponed on would help as well as the implementation proposed for #2546212: Entity view/form mode formatter/widget settings have no translation UI overall.
Comment #4
Gábor HojtsyComment #5
tstoecklerAhem, that makes this definitely not Minor. Not sure if it should be Major even, I'll let others decide that. Thanks for the info!
What I meant was the following:
The Configuration Translation module works in a way that can point it to a route and tell it what config objects to translate and then it adds new routes that live under
/translate
for the translation UI. We call these things "config mappers".Benefitting from the generic integration we have for config entities, you can already translate text formats at e.g.
/admin/config/content/formats/manage/basic_html/translate
. Thus a config mapper already exists for text formats. Because Text Editor module enhances the text format UI and adds corresponding config objects, so it should also enhance the text format translation UI to add the respectiveeditor.editor.*
config object to the text format mapper.Writing this, I realize this in fact needs #2577761: We need a way to dynamically alter the list of config names for config mappers in order to work. Once that is in, editor module could add an event subscriber which listens to the
ConfigTranslation::POPULATE_MAPPER
event and then does something like:(or similar)
EDIT: Massive x-post!
Comment #6
tstoecklerComment #7
Wim LeersUpdating status to reflect reality. Blocked on #2577761: We need a way to dynamically alter the list of config names for config mappers, hence marking as postponed. And since #2577761 was moved to 8.1, also moving this issue to 8.1.
Comment #14
tacituseu CreditAttribution: tacituseu commented#2577761: We need a way to dynamically alter the list of config names for config mappers is in.
Comment #15
Wim LeersSo this now just needs to do something like
\Drupal\config_translation_test\EventSubscriber\ConfigTranslationTestSubscriber
, or #2546212-90: Entity view/form mode formatter/widget settings have no translation UI. Let's do it!Comment #16
Gábor HojtsyYay, finally possible to fix :)
Comment #17
Wim Leers@Gábor Hojtsy: Is that a response to #15 or did something else happen recently? :)
Comment #18
Gábor HojtsyNothing recently other than some activity in #2546212: Entity view/form mode formatter/widget settings have no translation UI that prompted me to look here as well.
Comment #20
BerdirIn spirit of https://twitter.com/berdir/status/1113529017410387970, adding one more patch to our project :)
This is very much a proof of concept, I didn't do a lot of testing and, and as the example of the stylescombo config shows, it will most likely need more config changes.
Also, as always, integrating two modules that don't depend on each other is tricky, especially with events, add a class_exists() check as workaround for that now, we really should have module dependencies on services...
Comment #21
Berdirforgot the proof that it works:
Comment #22
tstoecklerWhy is the langcode check needed? I wouldn't have thought that to be the case.
Comment #23
BerdirAbsolutely no clue, the test does that? :)
Comment #24
ytsurkYes. I got it only working with the langcode check removed.
The mapper's language was NULL in my case, where the standard config language is German.
Comment #25
ytsurkAlright, this now throws an error if the config file (editor.editor.[format_name]) does not exist yet, thus has not editor:
Again in a setup where German is the default config language.
Caused by ConfigNamesMapper's:
So we need to skip filter formats not having a WYSIWYG editor.
Comment #26
ytsurkHere a new patch checking if the filter format has an editor set.
Comment #27
ytsurkComment #28
tstoecklerThanks for your work @ytsurk!
So if I understand you correctly the latest patches fixes the issue you were seeing in regards to different languages? If so, great! The patch looks good and makes a lot of sense. Now we just need a test for it. Marking "needs work" for that.
Also I see two possible follow-ups:
ConfigTranslationTestSubscriber
Comment #29
ytsurkComment #30
BerdirReroll after #3063020: Support translation of the list of styles in CKEditor which tried to fix this too but that's not enough.
I'm adding a basic translation test,
Comment #33
Wim Leers🤓
{inheritdoc}
🤓 s/random/randomly/
🤓 s/ckeditor/CKEditor/
🤯
Übernit: excess whitespace.
Shoudln't this be typehinted?
Nits:
- s/editor/text editor/
- s/filter format/text format/
Comment #34
shubham.prakash CreditAttribution: shubham.prakash at OpenSense Labs commentedPatch added for issues mentioned in #33.
Comment #36
shubham.prakash CreditAttribution: shubham.prakash at OpenSense Labs commentedComment #37
Wim LeersThanks, @shubham.prakash! 👍 Could you please provide an interdiff in the future? That makes reviews much easier! 🙂
Manually compared. Looks good! Two remaining remarks:
🤓 This line now is longer than 80 cols. The last word needs to be moved to the next line.
Comment #38
shubham.prakash CreditAttribution: shubham.prakash at OpenSense Labs commentedThanks for the review, I would make sure to provide interdiff now.
I am not sure about the type hinting as why it gave failed test cases in #34.
The commented line has been wrapped as said.
Comment #39
Wim LeersAha, I missed that!
You forgot the
use
statement, and that's why it failed the way it did. Typehinting + importing the correct interface through ause
statement should work fine 🙂Once that's done, this is ready!
Comment #40
shubham.prakash CreditAttribution: shubham.prakash at OpenSense Labs commentedHope this resolves the issue.
Comment #42
Wim LeersIt did! :)
The remaining failure is now due to the newly added requirement that you specify a
$defaultTheme
property on your test class.Comment #43
shubham.prakash CreditAttribution: shubham.prakash at OpenSense Labs commentedComment #44
aleevasComment #45
Wim LeersPerfect, thank you!
Comment #46
alexpottCommitted and pushed f68812c39a to 9.0.x and 9c054814f3 to 8.9.x. Thanks!
Comment #47
alexpottAsked the other committers about backporting this to 8.8.x
Comment #50
alexpottDiscussed with @catch who +1'd the backport.