Hello,

I have got an issue with i18n_menu: I can't get paths to be correctly translated with ckeditor_link.
Context:

  • Drupal 7.56
  • i18n 7.x-1.14
  • ckeditor_link 7.x-2.x-dev
  • A lot of other modules...

Here is an illustration of my problem for a menu entry that targets "/projects" in EN, and "projets" in FR:

  1. Switch the site to FR
  2. Create a content type with a ckeditor WYSIWYG as body
  3. Create a link of type "URL" in the body manually entering "/fr/projets" as the target :

    Create a URL manually targeting "/fr/projets"
  4. Save and view the node: Works as expected, the link does target "/fr/projets"
  5. Now edit this node again, click the link and edit it.
  6. At this moment, ckeditor_link seems to kick in and it converts the link to an internal link targeting "Projets (fr/projects)" :

    Link got converted to internal link with wrong URL

    That is wrong: URL "/fr/projects" is invalid as it has the FR language prefix followed by the EN alias.
  7. Save and view the node: the link now targets "/fr/projects", which is not what I want. Even though the link does work (somehow Drupal fallbacks to the technical English URL I guess) it is not great for SEO

Workaround found: add a '#' at the end of the target URL prevents ckeditor_link from detecting the link as one of its internal links, which doesn't seem normal to me neither but at least make it possible to "force" a link to stay untouched by ckeditor_link.

Comments

pacproduct created an issue. See original summary.

pacproduct’s picture

Version: 7.x-2.4 » 7.x-2.x-dev
StatusFileSize
new535 bytes

I tried patching the module but I must say I'm a bit confused and I'm not sure to fully understand how the module has been designed... I hope someone else will be able to enlighten me :)

My understanding is that ckeditor_link is designed to insert technical links only into the HTML, so that they get converted to their aliased and internationalized links when displaying the node.
That is where the hook_ckeditor_link_TYPE_url() hook comes in, making this conversion possible.
Is that correct?

I added this hook to the existing plugin ckeditor_link.i18n_menu.inc as follows (see attached patch):

function ckeditor_link_ckeditor_link_i18n_menu_url($path, $langcode) {
  return ckeditor_link_url($path, $langcode);
}

Now the behavior I described in the initial post is slightly better, even though not entirely satisfactory in my opinion. Here is how it works with this added hook:

  1. Switch the site to FR
  2. Create a content type with a ckeditor WYSIWYG as body
  3. Create a link of type "URL" in the body manually entering "/fr/projets" as the target :

    Create a URL manually targeting "/fr/projets"
  4. Save and view the node: Works as expected, the link does target "/fr/projets"
  5. Now edit this node again, click the link and edit it.
  6. At this moment, ckeditor_link kicks in and still converts the link to an internal link targeting "Projets (fr/projects)" :

    Link got converted to internal link with wrong URL

    This is still counter-intuitive even though on a technical level I kind of understand that it means the link should target the French version of the technical link "/projects".
  7. Save and view the node: now the link correctly targets "/fr/projets", which is what I wanted.

Any insight on this?
Any better idea on how to improve this? :)

Note: Patch and code retested against 7.x-2.x-dev this time.

pacproduct’s picture

Issue summary: View changes
simon georges’s picture

Status: Active » Needs review