Beta phase evaluation
Prioritized changes | The main goal of this issue is usability, fixing UI expectations on edit forms. |
---|---|
Disruption | No disruption outside of CKEditor's own implementation. Just fixes internal logic for the CKEditor translation display. |
Problem/Motivation
CKEditor module sets up translation for its user interface even if the Drupal interface translation module is not enabled. To reproduce this, just enable Language module (NO other language modules) and visit a node creation or editing page with the path prefix of the language.
Proposed resolution
Only translate the CKEditor user interface if the Interface translation (locale) module is enabled.
Remaining tasks
Patch. Review. Commit.
User interface changes
CKEditor will only be translated if Interface translation module is also enabled.
API changes
None.
Original report by Charles Belov
Steps (note there is a simpler list of steps above the image in the summary):
1. Create site
2. Go to /admin/modules
3. Check Content Translation
4. Check Language
5. Click save
6. Go to /admin/config/regional/language
7. Add language Spanish
8. Save
9. Go to /admin/structure/types/manage/page
9a. Click Language settings tab near bottom
10. Check Show language selector on create and edit pages
11. Check Enable translation
12. Save
13. Go to /node/add/page
14. Enter page content
Title: test page 1
Body: This is a test of an English page
15. Save and publish
16. Click Translate tab
17. On the Spanish row, click Add
18. Enter translation
Title: prueba de la página 1
Body: Esta es una prueba de la traducción al español de una página de Inglés
Actual without patch: CKEditor interface is in Spanish
Actual with patch #41: CKEditor interface is in English
Expected: CKEditor interface is in English
19. Save and keep published
20. Click edit tab
Actual without patch: CKEditor interface is in Spanish
Actual with patch #41: CKEditor interface is in English
Expected: CKEditor interface is in English
Comment | File | Size | Author |
---|---|---|---|
#56 | interdiff.txt | 2.22 KB | Gábor Hojtsy |
#56 | 2318237-ckeditor-language-56.patch | 4.08 KB | Gábor Hojtsy |
#54 | interdiff.txt | 1.72 KB | Gábor Hojtsy |
#54 | 2318237-ckeditor-language-54.patch | 4.04 KB | Gábor Hojtsy |
#51 | interdiff.txt | 980 bytes | Gábor Hojtsy |
Comments
Comment #1
bserem CreditAttribution: bserem commentedI couldn't reproduce this as explained.
I could only reproduce this when I enabled interface translation and switched the UI language to something other than English.
Even with UI translation on, I was getting an english version of ckeditor when my UI was in english (/en/* path).
The ckeditor was changing language when I was under some other language path (/es or /el).
Either this got fixed since August, or I failed to reproduce it and got the expected behavior!
Comment #2
Charles BelovConfirmed not happening in alpha15 as originally posted. I've updated the steps to show how to reproduce it in alpha15.
Comment #3
Charles BelovComment #4
Charles BelovConfirmed that it was an issue at step 17 in alpha14 but not in alpha15.
Still an issue at new steps 21-22 in alpha 15 (steps reproduced in alpha14, although by now that's a moot point).
Comment #5
bserem CreditAttribution: bserem commentedI can confirm the bug even with "interface translation uninstalled/disabled.
When clicking the 'edit' link on a translation you are being guided to a path like:
example.com/en/node/7/edit
example.com/es/node/7/edit
example.com/el/node/7/edit
And ckeditor takes the language from the corrensponding path.
Instead, the correct path (which exists and works, it was easy to guess) should be:
example.com/en/node/7/translations/edit/el
example.com/en/node/7/translations/edit/es
NOTE: on the above links the breadcrumb doesn't work properly.
Comment #6
bserem CreditAttribution: bserem commentedFile ContentTranslationRouteSubscriber.php:109 in /core/modules/content_translation/src/Routing
is correct. For some reason it seems like Drupal doesn't take this into account.
Delete Routing, starting at line 135 on the same file, works fine.
UPDATE:
by the power of
greyskull, eerrr grep I mean, I found that the routing that prevails is located atmodules/node/node.routing.yml:9
I'm kinda spamming this topic, sorry, but it has some fun trying to understand all these new D8 routing and yml stuff :)
Comment #7
Wim LeersYou're not spamming at all, thanks for your awesome detective work! :)
Comment #8
bserem CreditAttribution: bserem commentedWell, I could use a hint on where to look next. This one seems tricky.
I mean, "all we need to do" is alter the edit button to point to a different url if translations are enabled.
It could be silly easy, I just don't get how I can do something like that. Todays sessions helped a bit with the new routing systems though.
Comment #9
bserem CreditAttribution: bserem commentedFound it!
Attached patch (marked v1) solves the problem and points the user to the correct url for translations.
Please test and provide feedback.
Please consider v1 of the patch for the current issue and not v2 below.
However, it doesn't solve another problem I found:
If you have interface translation enabled, when clicking to edit the original language of the node you are swapped to that language for the interface.
I am submitting a second patch (marked v2) that actually solves this problem but makes the assumption that we address the original content as a translation too.
I suggest a new issue is made for the new problem since it is a bit irrelevant from the current issue. That is unless you find the attached patch acceptable :)
Comment #10
bserem CreditAttribution: bserem commentedPerhaps the attached approach makes more sense.
The problem originally originated by the fact that the user had right to edit the original node, so the code was never executing the
elseif
part.My first patch seperated the elseif, thus if the entity is a translation both ifs are executed and the second one overrides the first.
The new patch actually checks if the entity is the original piece of content, and if not then the elseif part is being executed.
ps: if promise I won't post another patch till the sun rises
Comment #14
bserem CreditAttribution: bserem commentedOh... I need to checkout out tests on D8 too
Comment #15
Wim Leers@bserem: awesome work! :) Thank you!
I think Gábor or somebody else from the D8MI team should review this. The patch in #10 is the one to be reviewed.
Comment #16
Wim LeersBack to NW to fix the tests.
Comment #17
Gábor HojtsyCan we get an updated issue summary first? What worked and did not work at different times is mixed in the summary. Its hard to tell what is the scope of the fix here?! I can review once we get an updated summary of the problem.
Comment #18
bserem CreditAttribution: bserem commented@Gabor: comment #5 properly illustrates the issue:
The fix tries to send you to the correct path, as described above.
The patch fails testing because the testing mechanism also needs to be updated (how? I wonder)
Comment #19
Wim LeersComment #20
no_angel CreditAttribution: no_angel commentedattempt at issue summary
Issue confirmed on alpha 14 and 15, but seems ok on beta 2
Comment #21
Gábor Hojtsy@no_angel: so looks like part of this report does not apply anymore. What applies still of the bugs mentioned?
Comment #22
Charles BelovIn beta3, without the patch, I get "Fuente HTML" on steps 17 and 20 (didn't test 21).
In beta3, with the patch, simplytest.me gives the error "An error occurred while patching the project."
Comment #23
bserem CreditAttribution: bserem commentedThe patch was not against beta3.
@Charles, can you try patching on git and see if it works?
Also, in order for the patch to pass testing, the test functions need to be updated to (which I'm having difficulties to do).
Comment #24
Charles Belov@bserem, I'm a total newbie at that sort of thing. Can you point me to a step-by-step article that explains the process?
Comment #25
bserem CreditAttribution: bserem commentedYour source is here: https://www.drupal.org/patch/apply
and for all things patch: drupal.org/patch
In general, the easiest way is to use: patch -p1 < file.patch
but if you are to spend time with Drupal then if makes sense to invest into the basics of git (you won't learn everything in the first day, but it is good to know where/what to search for).
If you need anything else please do not hesitate (you can also find me on irc)
Comment #26
Wim LeersEven simpler to test the patch: use simplytest.me. Use this link: http://simplytest.me/project/drupal/8.0.x?patch[]=https://www.drupal.org...
Comment #27
no_angel CreditAttribution: no_angel commented@Wim Leers
http://simplytest.me/project/drupal/8.0.x?patch[]=https://www.drupal.org...
> "An error occurred while patching the project"
Comment #28
Wim LeersThis is actually a
content_translation
issue, which explains much of the confusion here.Re-uploading the patch in #10, but rerolled against HEAD. Now you will be able to test using simplytest.me, via this link: http://simplytest.me/project/drupal/8.0.x?patch[]=https://www.drupal.org....
Comment #29
Wim LeersComment #30
Gábor HojtsyHow does fixing a link solve interface elements translated?
Comment #31
Wim LeersThis issue desperately needs an issue summary update, it's almost impossible to understand what the exact problem is, and how the patch solves the problem.
Comment #32
bserem CreditAttribution: bserem commented@Gabor I've already replied that to you in #5 and #18.
Drupal calls the wrong link, which displays translated interface elements. The correct links exists inside Drupal and if you call you get the correct translation.
Comment #33
Gábor HojtsyAll right, despite us repeatedly asking to please update the summary with current information, that did not seem to get anyone looking into that. So I went ahead and set up a D8 dev site to look into this and I think the complete bug report is entirely misguided. When you go add a Spanish translation or edit a Spanish translation, you get to a Spanish page. The URL starts with /es/... Its a Spanish page. The bug is that everything else is not Spanish not that the CK controls are Spanish. Once you also import Drupal translations for Spanish (because there is a hiccup in the automated download, I downloaded manually from https://localize.drupal.org/translate/languages/es and imported in Drupal), you get the whole page nicely in Spanish as indicated by the URL it should be:
Sounds like this bug is "There are Spanish things displayed on a Spanish page" or if you did not expect it to be a Spanish page then "I did not expect this *page* to be Spanish", not that some CK buttons are Spanish or not.
Comment #34
Gábor HojtsyUpdated the issue summary and retitled.
Comment #35
Gábor HojtsyComment #36
Gábor HojtsyNote that there is an administration language setting in Drupal 8 that you can enable for users to stick to English which will override whatever default content translation things it sets, so this issue is merely about what defaults should content translation set.
Comment #37
bserem CreditAttribution: bserem commentedOnce again you do not get the problem.
As I have explained: the problem happens without enabling interface translation.
When you go to translate a node (content translation) you get translated elements on CKeditor and only there
In the above image, nothing should be in greek (or spanish) but in english.
Does it make sense now?
I had nothing to update to the summary because I've explained the problem both in #5 and #18. Also, the original author had explained it pretty well (at least I understood what he meant).
On this image, check the url. After simplytest.me you get a /el but you should get a /en.
Interface translation is not enabled.
Comment #38
Gábor Hojtsy@bserem: the part the URL you squared indicates the source language of the translation. If you would be translating to Greek from Spanish, then that part of the URL would be 'es'. That part of the URL is not indicative of what language the page should be displayed in. The part of the URL indicative of what language to display the page in is the first part, in your case /el/ after the domain.
We can also repurpose this issue to say CKEditor should not translate its interface when the interface translation module is not enabled, even if the URL indicates a different language. Then the proposed patch is not dealing with the problem. I retitled and updated the issue to deal with that the patch tries to achieve but we can go the other way around as well.
Comment #39
Wim LeersSo the actual problem is that CKEditor is translated as if interface translation is enabled, even when interface translation is disabled?
Comment #40
Gábor HojtsyAll right then, let's retitle and repurpose this again. The goal of you doing this was to make it represent your opinion but we can play "Does Gábor get it" as well. Updated the summary again with the attached screenshot. No content translation module required to reproduce the bug, so the patch is not related to the problem, therefore setting to active. Needs patch then.
Comment #41
Gábor HojtsyProposed fix. Needs tests.
Comment #42
Wim LeersPatch makes total sense.
Charles Belov, bserem: please test this patch!
Comment #43
bserem CreditAttribution: bserem commentedPatch #41 gives the correct interface language but creates a path like example.com/[wrong-language-code]/node/1/translations/add/[source-lang]/[target-lang].
The first language code shouldn't be there in the first place I suppose.
As for the patch in #10, I never said it was correct. It was just my attempt to fix the problem.
Comment #44
Charles BelovI appreciate the summary. That said, something got lost in the translation from steps to summary. I'm not sure why my original steps to reproduce have been removed; is that typical for a summary?
My original issue was as follows:
Language is enabled
Content translation is enabled
Interface translation is not enabled.
Actual is that CKEditor is translated
Expected is the CKEditor is not translated
The following may be outside the scope of the current issue, and I need to discuss it anyway so that my expectation is clear.
Even if interface translation were enabled, if the person who is signed on prefers to interact with Drupal in English, the interface would correctly present to them in English even if they are editing a page for which Drupal is capable of interface translation. After all, they could be copying and pasting text that someone else gave them (a common scenario on our Drupal 7 website).
That is, the page language and interface translation language always need to be independent of one another.
For example,
I choose to interact with the Drupal interface in English regardless of content language.
My coworker prefers to interact in Spanish regardless of content language.
If we were editing an English page, I would see English content and interface. My coworker would see English content and Spanish interface.
If we were editing a Spanish page, I would see Spanish content and English interface. My coworker would see Spanish content and interface.
Bringing things back to the current issue: If interface translation is not enabled, there should be no interface translation.
Comment #46
Charles BelovRestoring original steps to summary.
Comment #47
Charles BelovComment #48
Charles BelovCorrected steps restoration.
The patch in #41 works for me in alpha4.
Comment #49
Gábor Hojtsy@Charles Belov: @bserem said to ignore the interface translation problem and focus on ckeditor instead. If we focus on CKEditor then the same problem applies to /es/node/add/page and does not require content translation, which makes for an easier to reproduce recipe for the bug, much less steps, you don't even need content translation module enabled.
If you prefer to administer the site in a certain language, then see #36 on how to set it up.
We can keep your extended steps list in the summary but just enabling language module and adding a language on the standard install is perfectly enough to reproduce the CKEditor bug that #41 is fixing, so the rest just serves to mislead people. Unless of course you want to solve a different bug, which I assumed from the prior patch but been informed by @bserem that would not be the case.
Comment #50
Gábor HojtsyThe test would look something like this plus-minus some container rebuilding or service resetting, we'll see.
Comment #51
Gábor HojtsyShould save config of course. Also adding some phpdoc.
Comment #54
Gábor HojtsyFixed the locale table fail and properly resetting the language manager and the ckeditor plugin. Passes locally.
Comment #55
Wim LeersLooks great, thank you!
Just one problem in the comments and one nitpick. After that, this is RTBC.
s/CK/CKEditor/
s/entity_load/Editor::load/
Comment #56
Gábor HojtsyFixed those. I copied the entity_load() from other parts of this file. I fixed it now at one more place which was in scope of the changes, but not in the remaining places that would be unrelated.
Comment #57
Wim LeersLooks great, thanks!
Comment #58
Gábor HojtsyComment #59
Charles Belov@Gábor #49: I have no idea about who in this issue has decision authority and who does not, so I have no way of knowing whether your comments or @bserem's comments carry more or the same weight.
From a user perspective, the CKEditor is part of the interface, and the user would reasonably expect the CKEditor translation (or not) to behave the same as the rest of the interface, as distinguished from the content. I was not complaining of any misbehavior on the part of the interface outside the CKEditor; I was simply saying what the user perspective is as I see it, focusing on the expected behavior rather than what the URLs read.
So far as I know, the interface outside the CKEditor is not misbehaving, and the issue I filed was strictly related to the misbehavior of CKEditor, and my comments are intended to be focused on that. That said, I was concerned that comments like #33 would lead to a Drupal 8 where the interface as a whole was translated when I would expect it not to be translated.
Comment #60
Gábor Hojtsy@Charles Belov: while you opened the issue, @bserem actually posted more on the issue than you. To fix a problem, we first need to define what it is. Looks like we arrived at the problem that CKEditor displays translated even if interface translation should not even happen on the site and have a fix with tests to ensure that is fixed and will not reoccur. Given your use case is you are not going to enable the interface translation module as far as I understand, this should completely fix your problem.
If you happen to enable the interface translation module later and still want to force certain preferred administration languages, see comment #36 where I explain where does Drupal provide that feature built into Drupal 8 (that feature is not enabled by default).
Now let's get this in with a core committer :)
Comment #61
bserem CreditAttribution: bserem commentedThe last patch, like the previous one, solves the issue with the CKEditor elements being translated. It doesn't solve the issue with the paths of the translation page which are like:
http://s61aed9511db1e2b.s3.simplytest.me/af/node/1/translations/add/en/af
One would expect a path like:
http://s61aed9511db1e2b.s3.simplytest.me/node/1/translations/add/en/af
since interface translation is not enabled, right?
This link works, but you are directed to this when you click to add a translation.
It is not critical and I don't even know if it is an issue or something that changes with D8.
As for why the issue took a turn, when I started with it, I couldn't reproduce the problem (first comments) but it was clear that there was a problem with translated elements.
Comment #62
Gábor Hojtsy@bserem: when I clarified the problem in #34-#36 to articulate your path problem you said in #37 that I did not get the problem and we should focus on solving this without interface translation when regardless of what path prefix you use, nothing will be translated on the screen (after CKEditor is fixed thanks to this patch). So we focused on that one. It does not matter without interface translation what the path prefix is. We changed course back to the CKEditor problem because you asked for that exactly.
Comment #64
BerdirTwo random fails, entity query again (please review #2397297: EntityQueryTest::testCaseSensitivity() can fail randomly) and a weird twig template fatal error...
Comment #66
Gábor HojtsyUpdated with beta evaluation in hopes that it would help get it committed :)
Comment #67
alexpottThis patch fixes the bug outline in the issue summary - if there are other bugs let's open new issues and reference this one. Thanks.
Committed bb03d39 and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation to the issue summary.
Comment #69
Gábor HojtsySuperb, thanks!
Comment #71
kate_kalashnikova CreditAttribution: kate_kalashnikova commentedHello guys! I know the issue is fixed, but it's the closest issue I found to my problem.
Here's the problem:
To translate block titles I had to turn on Configuration Translation that requires Interface Translation.
When editing Chinese translation CKEditor becomes in Chinese though I don't want it to be translated (other UI is still English).
I didn't find settings to turn it off. Could somebody please help me?
Thank you!