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

jhodgdon’s picture

Version: » 7.x-1.x-dev
jhodgdon’s picture

Status: Active » Fixed

Got this taken care of. I've tested on my test site by adding a fake other language. Seems to work fine.

  • jhodgdon committed bc4ca18 on 7.x-1.x
    Issue #2509110 by jhodgdon: Add multi-language view to editor
    
jhodgdon’s picture

Status: Fixed » Needs work

Oh, 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):

Drupal.ajax.prototype.eventResponse = function (element, event) {
...
  try {
    if (ajax.form) {
      if (ajax.setClick) {
...
// This is the line where the error is triggered...
      ajax.form.ajaxSubmit(ajax.options);
    }
  catch (e) {
// This is what generates the message
     alert("An error occurred while attempting to process " + ajax.options.url + ": " + e.message);
  }

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.

jhodgdon’s picture

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

  • jhodgdon committed d917f8a on 7.x-1.x
    Issue #2509110 by jhodgdon: Support translating with links to other...
jhodgdon’s picture

Title: Add multi-language view to editor » Support translating with links to other languages on editor
Status: Needs work » Fixed

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

jhodgdon’s picture

Title: Support translating with links to other languages on editor » Support translating on editor page

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

  • jhodgdon committed 2374b9e on 7.x-1.x
    Issue #2509110 by jhodgdon: Support translating with display of source...

Status: Fixed » Closed (fixed)

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