Kunena/Kunena-Forum

发帖时没有编辑选项

17gather opened this issue · 14 comments

Thank you for the report, we will looking soon at the issue

So what is the issue ?

Please provide more details : Kunena version used, kunena template used

In which case it doesn't load like you show ti on your second screenshot ?

@17gather Please post the problem in the forum: https://www.kunena.org/forum/recent
Github is for development and not for support.

This issue is stale because it has been open 30 days with no activity.

I can reproduce the issue. Correct title for this issue would be 'Message editor does not load'.
The reason is that if you use Kunena in a different language than English, the CKeditor (behind the MEssage editor) tries to load a language specific file from /media/kunena/core/js/lang .
So, for Spanish it would look for /media/kunena/core/js/lang/es.js.
However, these files are not provided, neither in the base package, nor in the language package.
Copying them from the standard CKeditor package resolves the issue.

I can only reproduce the issue in Chrome, not in Firefox, btw.

I can only reproduce the issue in Chrome, not in Firefox, btw.

Maybe a cache problem.
I have tested it and cannot reproduce this problem. The language pack on our download page contains both the Spanish and the Chinese language of the topic author.
Both language scripts are installed, provided that this language is already installed in Joomla. Download and installation of the current language file, solves both language problems and so i close this ticket.

Why was this closed? I can reproduce it right here. It is NOT a cache problem.

Firefox seems to be a bit more lenient, as it does not crash out on the following JS when the particualr language file cannot be loaded.
The files are definitely missing.

Then I open the ticket again, although the error cannot be reproduced. I have tested it with Chromium, Firefox and Opera.
.
Bildschirmfoto vom 2024-09-04 13-15-15
.
image10

I did not write that the language pack is not installed. I wrote that there are missing files for CKeditor.
In the directory
/media/kunena/core/js/lang there is only en.js

The Kunena language pack does not add any .js files to that directory, but in my Kunena installation for a Spanish user the editor starts to look for a file /media/kunena/core/js/lang/es.js - which does not exist and causes the editor window not to load.

Why does it do that? I am trying to figure that out right now.

I might have a lead what is going on.
First of all, yes the Kunena language package contains the ckeditor JS file (I was wrong here), but I can see is that the package only installs the languages that are currently installed in Joomla. This was unexpected. It means whenever I install a new language I need to re-install the Kunena Language pack.

Anyway, in our particular configuration however we have es-MX as language saved as default in the user profile. The language does not exist in the site, anymore, and Joomla is handling this gracefully.

Kunena however tries to load the language file for the non-existing language, failing to do so, and so the editor does not appear.

This imho happens because in ckeditor_config.js just sets whatever is set as language in the user profile without checking if the language does even exist in Joomla.

	if (Joomla.getOptions('com_kunena.ckeditor_userdefaultlanguage') != 'default') {
		config.defaultLanguage = '' + Joomla.getOptions('com_kunena.ckeditor_userdefaultlanguage') + '';
	} else {
		var joomlaLanguage = Joomla.getOptions('com_kunena.ckeditor_joomladefaultlanguage');

		if (joomlaLanguage != 'en') {
			config.defaultLanguage = '' + joomlaLanguage + '';
		}
	}

See ckeditor.php

$user = Factory::getApplication()->getIdentity();
$userLanguage = $user->getParam('language', 'default'); // Needs a check here if the language is even installed
$joomlaLanguage = Factory::getApplication()->getLanguage()->getLocale();

Fix:

In the top of ckeditor.php add

use Joomla\CMS\Language\LanguageHelper

Following lines after the above code would imho fix this:

$user = Factory::getApplication()->getIdentity();
$userLanguage = $user->getParam('language', 'default'); // Needs a check here if the language is even installed
if (!LanguageHelper::exists($userLanguage)) { 
   $userLanguage = 'default';
}
$joomlaLanguage = Factory::getApplication()->getLanguage()->getLocale();