We should use relatve url, otherwise module like locale can not load the JS files to parse text.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jcisio’s picture

IMO we should get rid of the "local paths" (i.e. URLs) and use url() to detect them. Because now local paths are determined at the config time (and are saved in the profiles), if you export profiles into a module, it won't work when you move CKEditor module folder (e.g. from sites/all/modules/ckeditor to sites/all/modules/contrib/ckeditor).

There are a few issues filed because of those "local paths", for example #1961974: Ckeditor is not loading via Edit module when custom plugins are enabled.

wwalc’s picture

That might be a good idea, but I'm wondering if it will not break anything, especially if CKEditor or plugins are located outside Drupal in some way... definitely something to investigate.

jcisio’s picture

You mean outside the Drupal docroot? We can simply say: "it is not supported". Just move them to sites/all/libraries, or symlink them. That will also help custom plugins (those not shipped with CKEditor and tightly integrated into Drupal) to be translated/managed via localize.drupal.org by a lot of users, and use only one lang.en.js. We moved from PO files to localize.drupal.org because of exactly the same reason.

wwalc’s picture

Okay, fair enough. Would you be okay with providing a patch for it?

jcisio’s picture

Sure, I'm looking in it when I have some free time, hopefully soon.

wwalc’s picture

Superb, thank you! I'll ofc gonna give it a try once available. Would be awesome to get rid of one more problem with non-standard solutions in this module.

jcisio’s picture

Just want to update: I didn't do it directly, but I tried to have a custom plugin automatically translated (replace 'text' with Drupal.t('text')), however it didn't work as I expected (need to drupal_add_js the lang.en.js file manually for locale.module etc.). I'll try another time.

jcisio’s picture

jcisio’s picture

lex0r’s picture

Priority: Normal » Critical
Issue summary: View changes

Using Drupal.t makes no sense in current 7.x version. I checked the module's (ckeditor's) JS plugins and they use Drupal.t which is misleading and just doesn't work. The D8 fix mentioned earlier is a core fix which is not supposed to be ported to D7.

At the moment there's no even a tiny patch to address the translation issue. It looks like we are going back to thinking everyone must know English. From my POV, this is a critical issue (users may not be able to use the editor).

I'm not sure the title of this post reflects the real meaning of the issue: Translation of js strings was a better choice, but it is now closed as duplicate. The current title (call to action) assumes someone had to make a quick fix (it sounds like that!) but it never happened.

lex0r’s picture

A simple way to have the issue fixed. It's not ideal however it does the job and seems to work well at least in admin zone of a site, where having JS loaded at once doesn't affect the end user.

jcisio’s picture

Title: Usage of ckeditor_path('url') for drupal_add_js » Replace usage of ckeditor_path('url') with drupal_add_js

I was hoping this issue was a simple fix for JS translation, but then it was also blocked by a similar problem in D8 core. Now it has been fixed in core, we can see how to port it here. locale_js_translate() doesn't exist in D7 and I haven't checked for a similar function in D7.

I think your patch is what it was in the first iteration in core. Using that, plugin files are executed twice. We should avoid that. I'm also not sure if dependencies (plugin order) work.

PS: not all things that don't work as expected are critical bugs.

lex0r’s picture

@jcisio,

just wanted someone to pay attention to this issue. It's been for such long time without even a not-so-good fix.

Btw, I found an issue with my previous patch so everyone should use the one attached below.

gifad’s picture

@jcisio : The scald project solves nicely this issue by using, in a hook_library() :

  // This file is included automatically if the CKEditor plugin is enabled.
  // However we need to load it directly in Drupal so that strings can be
  // translated.
  $plugin = ...;
  $libraries['library']['js'][$path . '/plugins/' . $plugin . '/lang/en.js'] = array();

Can't CKEditor do the same for its own plugins ?