Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bserem’s picture

I 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!

Charles Belov’s picture

Issue summary: View changes
Status: Active » Closed (cannot reproduce)

Confirmed not happening in alpha15 as originally posted. I've updated the steps to show how to reproduce it in alpha15.

Charles Belov’s picture

Status: Closed (cannot reproduce) » Active
Charles Belov’s picture

Issue summary: View changes

Confirmed 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).

bserem’s picture

I 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.

bserem’s picture

File 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 at
modules/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 :)

Wim Leers’s picture

You're not spamming at all, thanks for your awesome detective work! :)

bserem’s picture

Well, 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.

bserem’s picture

Found 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 :)

bserem’s picture

Perhaps 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

The last submitted patch, 9: 2318237-fix_edit_link_for_translations-9_v1.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 10: 2318237-fix_edit_link_for_translations-10.patch, failed testing.

bserem’s picture

Oh... I need to checkout out tests on D8 too

Wim Leers’s picture

Assigned: Unassigned » Gábor Hojtsy
Status: Needs work » Needs review

@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.

Wim Leers’s picture

Status: Needs review » Needs work
Issue tags: +DrupalCamp Ghent 2014, +sprint, +Novice, +php-novice

Back to NW to fix the tests.

Gábor Hojtsy’s picture

Assigned: Gábor Hojtsy » Unassigned
Issue tags: +Needs issue summary update

Can 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.

bserem’s picture

Status: Needs work » Needs review

@Gabor: comment #5 properly illustrates the issue:

I 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

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)

Wim Leers’s picture

Issue tags: -DrupalCamp Ghent 2014, -sprint
no_angel’s picture

Issue summary: View changes
FileSize
132.46 KB
125.17 KB

attempt at issue summary

Issue confirmed on alpha 14 and 15, but seems ok on beta 2

Gábor Hojtsy’s picture

Status: Needs review » Postponed (maintainer needs more info)

@no_angel: so looks like part of this report does not apply anymore. What applies still of the bugs mentioned?

Charles Belov’s picture

Issue summary: View changes

In 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."

bserem’s picture

The 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).

Charles Belov’s picture

@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?

bserem’s picture

Your 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)

Wim Leers’s picture

Even simpler to test the patch: use simplytest.me. Use this link: http://simplytest.me/project/drupal/8.0.x?patch[]=https://www.drupal.org...

no_angel’s picture

@Wim Leers

http://simplytest.me/project/drupal/8.0.x?patch[]=https://www.drupal.org...

> "An error occurred while patching the project"

Wim Leers’s picture

Component: editor.module » content_translation.module
Status: Postponed (maintainer needs more info) » Needs review
FileSize
1.36 KB

This 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....

Wim Leers’s picture

Issue tags: -php-novice +Needs tests
Gábor Hojtsy’s picture

How does fixing a link solve interface elements translated?

Wim Leers’s picture

Status: Needs review » Needs work

This 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.

bserem’s picture

@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.

Gábor Hojtsy’s picture

All 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.

Gábor Hojtsy’s picture

Title: Interface elements translated on translated pages for English user » Entity translations are created and edited on pages using the language of the translation
Issue summary: View changes
Issue tags: -Needs issue summary update +language-content

Updated the issue summary and retitled.

Gábor Hojtsy’s picture

Issue summary: View changes
Gábor Hojtsy’s picture

Issue summary: View changes

Note 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.

bserem’s picture

Once 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.

Gábor Hojtsy’s picture

@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.

Wim Leers’s picture

So the actual problem is that CKEditor is translated as if interface translation is enabled, even when interface translation is disabled?

Gábor Hojtsy’s picture

Title: Entity translations are created and edited on pages using the language of the translation » CKEditor translates its user interface even if interface translation is turned off
Component: content_translation.module » ckeditor.module
Issue summary: View changes
Status: Needs work » Active
Issue tags: -language-content +language-ui
FileSize
259.11 KB

All 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.

Gábor Hojtsy’s picture

Status: Active » Needs review
FileSize
1.28 KB

Proposed fix. Needs tests.

Wim Leers’s picture

Patch makes total sense.

Charles Belov, bserem: please test this patch!

bserem’s picture

Patch #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.

Charles Belov’s picture

I 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.

The last submitted patch, 28: 2318237-fix_edit_link_for_translations-28.patch, failed testing.

Charles Belov’s picture

Issue summary: View changes

Restoring original steps to summary.

Charles Belov’s picture

Issue summary: View changes
Charles Belov’s picture

Issue summary: View changes

Corrected steps restoration.
The patch in #41 works for me in alpha4.

Gábor Hojtsy’s picture

@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.

Gábor Hojtsy’s picture

The test would look something like this plus-minus some container rebuilding or service resetting, we'll see.

Gábor Hojtsy’s picture

Should save config of course. Also adding some phpdoc.

The last submitted patch, 50: 2318237-ckeditor-language-50.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 51: 2318237-ckeditor-language-51.patch, failed testing.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
4.04 KB
1.72 KB

Fixed the locale table fail and properly resetting the language manager and the ckeditor plugin. Passes locally.

Wim Leers’s picture

Status: Needs review » Needs work
Issue tags: -Needs tests

Looks great, thank you!

Just one problem in the comments and one nitpick. After that, this is RTBC.

  1. +++ b/core/modules/ckeditor/src/Tests/CKEditorTest.php
    @@ -368,6 +368,10 @@ function testLanguages() {
    +    // No locale module, so even though languages are enabled, CK should still
    
    @@ -377,11 +381,38 @@ function testJSTranslation() {
    +    // With locale module, CK should not adhere to the language selected.
    

    s/CK/CKEditor/

  2. +++ b/core/modules/ckeditor/src/Tests/CKEditorTest.php
    @@ -377,11 +381,38 @@ function testJSTranslation() {
    +    $editor = entity_load('editor', 'filtered_html');
    

    s/entity_load/Editor::load/

Gábor Hojtsy’s picture

Status: Needs work » Needs review
Issue tags: +sprint
FileSize
4.08 KB
2.22 KB

Fixed 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.

Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community

Looks great, thanks!

Gábor Hojtsy’s picture

Issue summary: View changes
Charles Belov’s picture

@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.

Gábor Hojtsy’s picture

@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 :)

bserem’s picture

The 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.

Gábor Hojtsy’s picture

@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.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 56: 2318237-ckeditor-language-56.patch, failed testing.

Berdir’s picture

Status: Needs work » Reviewed & tested by the community

Two random fails, entity query again (please review #2397297: EntityQueryTest::testCaseSensitivity() can fail randomly) and a weird twig template fatal error...

Gábor Hojtsy’s picture

Issue summary: View changes

Updated with beta evaluation in hopes that it would help get it committed :)

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This 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.

  • alexpott committed bb03d39 on 8.0.x
    Issue #2318237 by Gábor Hojtsy, bserem, no_angel, Wim Leers: CKEditor...
Gábor Hojtsy’s picture

Issue tags: -sprint

Superb, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

kate_kalashnikova’s picture

Hello 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!