newbthenewbd / grav-plugin-tinymce-editor

TinyMCE Editor Integration Plugin for Grav
Other
60 stars 10 forks source link

Language URL not loading #38

Closed pieter91 closed 4 years ago

pieter91 commented 5 years ago

I have my user account language set to something other than english. But the TinyMCE javascript doesn't refer to the correct language file in the language_url field. The value becomes "/" on the source of the edit page.

I'm not familiar enough with twig and grav to understand what's happening exactly. But wouldn't it be easier to set the language in the "language" field?

newbthenewbd commented 5 years ago

I don't think so, sadly, as, if I recall correctly, TinyMCE follows a language code standard that is different from the one Grav uses. The correct language is therefore guessed; the last time I checked, the system seemed to work pretty well, but I haven't tested all of the languages. I will try looking into it ASAP, although cannot promise anything, as for the few weeks to come my free time unfortunately stays scarce. Could You specify what language exactly it is?

Thanks for reporting!

pieter91 commented 5 years ago

I'm trying to load "nl".

As I said, I don't know enough about grav, but would it be possible to add a dropdown menu to the user account settings page in the admin interface? Or is that not allowed?

A good solution in my case would be to set a site-wide language for TinyMCE, circumventing the user's chosen language. But I can imagine that won't suit everyone.

newbthenewbd commented 5 years ago

From what I've acquired, this seems to be caused by a regression in the recent versions of Grav, specifically, the url() Twig function not working as it used to, and as documentation suggests it should. As of the time of this writing, the problem could have even been observed in the official Grav Documentation.

A workaround that I suggest until this change is confirmed to be deliberate, thus mandating the plugin's update, or a mistake, thus requiring changes to Grav, is to specify the language URL in the plugin's config, like this:

parameters:
  -
    name: fontsize_formats
    value: '6pt 7pt 8pt 9pt 10pt 11pt 12pt 13pt 14pt 15pt 16pt 18pt 20pt 22pt 24pt 26pt 28pt 32pt 36pt 40pt 44pt 48pt 54pt 60pt 66pt 72pt 80pt 88pt 96pt'
  -
    name: paste_data_images
    value: '1'
  -
    name: language_url
    value: '/user/plugins/tinymce-editor/js/tinymce/langs/nl.js'
pieter91 commented 5 years ago

Thanks for your help!

I added the language_url field to the plugin config, but I get the error message: Failed to load plugin url: /site/user/plugins/tinymce-editor/js/tinymce/langs/nl.js. This seems to be because the plugin's template is inserting the parameters into the plugins field in the tinymce.init function.

newbthenewbd commented 5 years ago

Change /site/user to /user, should work - the first version of my comment, and therefore the one that I suppose had been emailed to You, was mistakenly adapted for a website lying not in the document root, but under /site, as this is my local test configuration.

pieter91 commented 5 years ago

Oh, great, that fixed it! Thanks for the workaround.

I'll see what happens when there's an upgrade to Grav.

newbthenewbd commented 4 years ago

Closing, as it seems to me that this problem does not occur anymore - if that's not the case, feel free to comment or open a new issue.

Thanks!