[Solved] Wrong display date format in french (maybe other languages as well?)
First of all thanks for this awesome plugin. I'm implementing it since yesterday but I'm really enjoying it already.
Anyway I would like to report a bug in the display date format.
On French websites the date isn't displayed in the right format (maybe same issue for sites running with other languages?)
In English we write "2 weeks ago" > this is OK.
But in french we cannot say "2 semaines il y a" > this is wrong. We should say "il y a 2 semaines".
So the translated phrase "wc_ago_text" must come before the date value.
I've found a workaround by updating 3 lines in the dateDiff function in file"utils/class.WpdiscuzHelper.php"
Line 100 :
-- Removed -- $text = "";
++ Added ++ $text = get_locale() == "fr_FR" ? esc_html($this->options->phrases["wc_ago_text"]) . " " : "";
Line 127 :
-- Removed -- $replace = esc_html($this->options->phrases["wc_ago_text"]);
++ Added ++ $replace = get_locale() == "fr_FR" ? "" : esc_html($this->options->phrases["wc_ago_text"]);
Line 128 :
-- Removed -- $text = str_replace($search, $replace, $this->options->general["dateDiffFormat"]);
++ Added ++ $text .= str_replace($search, $replace, $this->options->general["dateDiffFormat"]);
It does the job fine as of now but of course it will be scrapped at the next plugin update 🙁
Would it be possible to tackle this translation issue in one of the next plugin updates ?
Maybe by creating an "exception array" for all the languages where "wc_ago_text" must come upfront ?
Thanks for reading and keep up the good job !
Please remove all the customizations you've made, then
navigate to Dashboard > wpDiscuz > Settings > General tab and find the "Structure of Human Readable Date Format" option. You can configure the date format with this option.