Closed bembelimen closed 2 years ago
The CMS uses => Date and the Framework uses DateTime, and the format methods are no the same.
So updating where this $app->modifiedDate is initialized across the CMS to use the DateTime class instead will solve this issue, I think...
Like in the Document class on lines 1189, so decoupling the modifiedDate
value from JDate basically, or is that not an option?
This is my take at a quick glance...
According to PHP's documentation, the DateTime::format()
"method does not use locales. All output is in English."
Did I miss something?
@nibra the point is that looking at the links I posted you will see that where the application gets used in the CMS, they pass the Joomla Date (JDate) to the application, and its not following the parent method function input for the format method.
So we have two options, the first as suggested by @bembelimen is to moving these lines into a method that can be overwritten in the CMS to allow the JDate override for the format method to work as expected, or my suggestion to decoupling the modifiedDate value from JDate.
Ok, so \Joomla\CMS\Date\Date
extends \DateTime
and overrides the format($format)
method with a different signature: format($format, $local = false, $translate = true)
, which is a problem of its own. Since $translate = true
, the date gets translated.
The proper way would be to provide the modifiedDate
as a clean \DateTime
object, which is what you, @Llewellynvdm, suggest, if I understand correctly.
Another way is \Joomla\CMS\Date\Date
moving the incompatible arguments to separate methods, like Date::setLocal(bool $local): Date
and Date::setTranslateable(bool $translate): Date
, so translation can be turned on and off as needed, leaving the signature of \DateTime::format()
intact.
Steps to reproduce the issue
See https://github.com/joomla/joomla-cms/pull/20905 which works very well for Joomla! 3. But as 4.x relies on the framework package only for the response, the Day will always be translated here https://github.com/joomla-framework/application/blob/2.0-dev/src/AbstractWebApplication.php#L393
Expected result
Date not translated
Actual result
Date is translated
Additional comments
I would like to prevent having to copy this whole "respond" method again into Joomla! so probably you have a suggestion? Extract it into an own method?
@nibra