-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mail notifying about new article is not properly built when site and backend languages are different #39228
Comments
Someone coincidentally reported the same issue on "Stack Exchange - Joomla" yesterday, see Workflow question: How to fix missing com_messages text?. I had answered my findings about languages being set to different ones and got response:
So it seems this is only dependent on the default language settings? This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39228. |
It's because |
@SharkyKZ Do you mean to say, that one cannot have the backend in one language, say English, and the frontend in a different language? But even if so, why would different default languages lead to a specific language file ( This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39228. |
Actually, it is loaded, but to a different $language instance. As @SharkyKZ mentioned, As of right now, I don't know if change |
@joomdonation Thanks. Let me first make clEar that my knowledge of the internals of Joomla are (still) very limited. So please bear with me and with what I write. Anyway, here I go... Global $language instance versus multiple instancesYour comment regarding the $language instances triggers some questions:
Even so ConclusionI still think there is a bug in this processing, or possibly a conceptual problem. Changing the Mail TemplatesInteresting: The mail template as shown in the editor does not show the language keys (e.g. Yes, this a better workaround than having to keep site and administrator languages equal. I prefer to have the backend in English. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39228. |
@phunsoft To understand this issue, please look at this code https://github.com/joomla/joomla-cms/blob/4.2-dev/administrator/components/com_messages/src/Model/MessageModel.php#L358-L359 . You will also have to look at the code here https://github.com/joomla/joomla-cms/blob/4.2-dev/libraries/src/Language/Language.php#L287 to understand how
As mentioned before, I agree that it is a bug here. I can see a solution, but I am unsure that it will be safe to make the change. So I pinged the author of this Mail Template feature so that he will have a look and we can discuss further if needed. For the time being, changing mail templates as I mentioned is an option Otherwise, change setting of the user account (which receives system message) to have backend language same with frontend would be another choice. Hope my explanation is clear to you. Understand this will require some code reading skill :). |
@joomdonation Thanks a lot for the pointers into the code. I'll go and have a look, since I'm curious to better understand the internals. I do have enough code reading skills, but as someone which does not yet understand all the compex concepts behind a certain software, it takes time to get into it. I had implemented the "keep languaes equal" workaround, but like the template workaround much better, so I switched to the latter. As a side note: Someone coicidentially reported the same problem on Stackexchange - Joomla. I had answered with the language workaround and will update with the template workaround now. Thanks for your time. Much appreciated! This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39228. |
You're welcome. One day we will fix it so that you don't have to use workaround :). |
If this would turn out to be too complex to solve for what ever reasons, I could think of a required post-installation step after installing a new languge: Create localized mail templates for all installed ones. And this could be supported by a message shown under System -> Warnings, or System -> Instllation Messages, if there are mail templates which do not have a localized version for each language that is installed. Just a thought that came to my mind. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39228. |
Not that hard. I just haven't looked at it carefully enough to if it is safe to change without causing any unexpected behaviors. |
It looks like this only happens with sites upgraded form joomla 3 to joomla 4. So it looks like that joomla 3 upgraded sites to Joomla 4 don't use the language file \language\com_content.ini This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39228. |
Fresh Joomla 5.1 If both languages are set as Swedish, e-mail displays O.K. but in Swedish. I don't get what is workaround here? Joomla forum thresd: https://forum.joomla.org/viewtopic.php?t=1009444#p3722752 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39228. |
Any news on this? |
should be fixed by #44243 |
Steps to reproduce the issue
en-GB
.de-CH
. (I tried also withde-DE
, andfr-FR
: Same result.)Content - Joomla
plugin.Expected result
Joomla should send a message with
Actual result
This works fine when the default language in the backend is set to the same language for "Administrator", and "Site".
With "Site", and "Administrator" default languages set to different languages, a mail is still being sent, but:
Above constants are language file KEYs, which are defined in file
administrator\language\<lang>\com_messages.ini
(where<lang>
is any of the above the language codes) as follows:Somehow the those keys are resolved to the corresponding values when languages are equal, but are not resolved when they are different.
System information (as much as possible)
This bug probably existed since Joomla 4.0 (and under PHP 7.x), I just hadn't time to investigate until now.
Additional comments
I was debugging locally using "Eclipse for PHP" to find out what's going on. Here is the result:
Class "Language" (
libraries/src/Language/Language.php
) has a property$strings
, which is an array to hold all "known" language "KEY=value" pairs to be used in translation. This array has some 1900 entries in the context where the notification mail is being prepared and finally sent by the "Content - Joomla" plugin.This array holds above "KEY=value" pairs (and some 70 more "COM_MESSAGES_..." keys) that are loaded from language file
administrator/language/<lang>/com_messages.ini
in the cases where the "Site", and "Administrator" languages match. Therefore a mail is being sent out as desired. This file is present for all the languages I've tested with, and the Keys in question are defined equally in each of the language variants.
In the case where the languages are different, it seems that this language file is not being loaded at all into the
$strings
array. Therefore the mail being sent out has the language keys in subject and body, instead of the desired text.Attachments
I'm attaching some files with information from the Eclipse debug sessions for both cases.
A summary of the test cases and results
New article and language setting testing resulting mail summary.txt
Some snippets of the debug session with selected variables listed.
New article and language setting testing with languages equal.txt
Complete array
$strings
in the language object.New article and language setting testing with languages equals $lang--strings[].txt
Some snippets of the debug session with selected variables listed.
New article and language setting testing with languages different.txt
Complete array
$strings
in the language object.New article and language setting testing with languages different $lang--strings[].txt
The text was updated successfully, but these errors were encountered: