Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
On #2505241: Handle translations I changed the code to handle the display and editing of a book with translations.
The way it currently works, you can be viewing the book in any language, and then you can edit that language's source. That is working fine.
As a follow-up, it would also be nice if when you were on the editor page, you could also open up (possibly read-only?) the source in another language as well, so that you could compare them while editing.
Comments
Comment #1
jhodgdonComment #2
jhodgdonGot this taken care of. I've tested on my test site by adding a fake other language. Seems to work fine.
Comment #4
jhodgdonOh, interesting.
I had trouble making this work on my original test site, due to some JS problems, but I got it working on another test site.
Then I realized the second test site didn't have all the AsciiDoc previewer JS installed. When I put that on the second test site, the dual-language feature stopped working -- the Ajax that loads the source fails.
So this needs some work. I'm not sure what's causing the failures, but something in the Drupal Core Ajax submit javascript is interacting with the AsciiDoc editor JavaScript and causing an error that says:
An error occurred while attempting to process /system/ajax: c.$class is not a function
When I saw this before on the other test site, I found that it was happening somewhere called from the Drupal ajax.js file, where it does (slightly edited):
So apparently the JS that runs the AsciiDoc editor is interfering with this.
It may be necessary to instead of what I did in the above commit (using the Drupal ajax callback functionality and default URL) to instead have a custom URL, but I'm not actually sure that will solve the problem.
Comment #5
jhodgdonOne more note on this, on my first (failing) test site, I tried a basic Ajax on that editor page and it failed too, which is why I moved to the other one where I knew Ajax was working (I thought it was just an outdated Drupal version or something). So... it's not specific to this particular Ajax callback.
Also on my first (originally working) test site, another page with that same simple Ajax on it is working.
So it is definitely the combination of trying to do any Drupal Ajax along with the AsciiDoc editor that is broken.
Comment #7
jhodgdonWell, I tried debugging this, but the Asciidoctor JS is kind of complicated, and I am not sure why it is firing due to the Ajax request on a different form. ?? But anyway, I just chose a different route. Instead of using Ajax to load the source of a different language, I decided to just put up links to edit the source in a different language, which open in a new window. So you can have English open in one tab, and Spanish or whatever in a different tab, and maybe Portuguese too. This seems like it will be fine, although maybe it is not ideal. We can always revisit later if it's a problem.
Comment #8
jhodgdonI added more to this today -- a text box with the Source language displayed. Had to add a new config setting for that, which also meant it made sense to rearrange the Admin edit page for a book config.
Anyway, I think this is pretty good now.