Hello Everyone!
Usually I can debug and fix things myself but in this case I'm out of ideas. I've already searched the forums and couldn't find a solution, so maybe you can help?
Environment: New website, clean install, working on a custom child theme based on the premium theme BeTheme. WordPress 5.9, everything up to date, no issues what so ever. Default WP language set to ro_RO (Romanian), I'm using Loco Translate to translate everything and it works fine without issues for the theme, child theme, other plugins etc - so all good there.
Problem: I've started traslating wpDiscuz, using Loco Translate, .mo/.po setting enabled and all that. Everything on the front-end seems to work ok, translations show up just fine for wpDiscuz. However when I've reached the email notification translations it's not working, I still get the notifications via email in English.
For example I'm having trouble translating this one: "wc_comment_approved_email_message"
from the default:
Hi [COMMENT_AUTHOR],<br/><br/>your comment was approved.<br/><br/><a href="[COMMENT_URL]">[COMMENT_URL]</a><br/><br/>[COMMENT_CONTENT]
to:
BunΔ [COMMENT_AUTHOR]!<br/><br/>Comentariul tΔu a fost aprobat!<br/><br/><a href="[COMMENT_URL]">[COMMENT_URL]</a><br/><br/><b>Comentariul tΔu:</b><br/>[COMMENT_CONTENT]
Which in the .pot file is set to be at class.WpdiscuzOptions.php line 417 (or 416, can't remember) but it wasn't there, neither was this one:
"wc_comment_approved_email_subject" => esc_html__("Your comment is approved!", "wpdiscuz")
Turns out that some of the entries in wpdiscuz.pot are not up to date, so I just synced the translation template in Loco Translate (and also synced my translation file located in languages/loco/plugins/wpdiscuz-ro_RO.po) and it added 10 new entries and removed 23 outdated. This fixed the inconsistency problem, now the translation entries correspond to the proper lines from class.WpdiscuzOptions.php, so "wc_comment_approved_email_message" is now at line 418 and that seems to be ok. But my problem still persists, even after checking everything I still get the English version via email.
I've cleared server, browser and all existing cache, disabled and re-enabled wpDiscuz, cleared it's internal cache, used the database tool "Fix Tables" (I enforce and use utf8mb4_unicode_520_ci for everything, I made sure of that), re-installed WP 5.9, disabled all additional plugins and the list goes on... I just can't find a way to make it work.
Any ideas why that particular email notification translation is not working? Any idea what could be or what to check / do?
Thank you!
Please follow the steps below:
1. Navigate to Dashboard > wpDiscuz > Settings > General Settings tab, disable the "Use Plugin .PO/.MO Files" option
2. Go to Dashboard > wpDiscuz > Phrases > General tab, scroll down find and click on the "Reset Phrases"Β button
3. Again go to to Dashboard > wpDiscuz > Settings > General Settings tab, enable the "Use Plugin .PO/.MO Files" option and check again.Β
Thank you for the prompt reply!
I followed your instructions and also did the whole checking process again after that, a few times in different ways, like changing the main WP language, re-saving Settings (for both WP and wpDiscuz), cleared wpDiscuz cache, enabling / disabling the use of .po/.mo files, reseting the Phrases and so on. It's still sending the English version via email.
It's not defaulting to the Phrase section templates when I enable the "use of .mo/.po files" because I checked that by changing the Phrases > Email > Comment approved message template... when "use .mo/.po files" is disabled I can see the changes I made in Phrases, when I enable "use .mo/.po files" it's defaulting to the one in the actual class.WpdiscuzOptions.php code NOT the Loco Translate one... so neither Loco Translate or the Phrases templates are overriding the php one in this case.
My default form was set to ro_RO and I've changed it back to en_US, that didn't fix it either.
I've also tested, with no luck, the translation for this email notification:
class.WpdiscuzOptions.php:352 - same issue, not showing the Loco translation.
"wc_email_message" => __("Hi [SUBSCRIBER_NAME],<br/><br/> new comment has been posted by the <em><strong>[COMMENT_AUTHOR]</em></strong> on the discussion section you've been interested in<br/><br/><a href='[COMMENT_URL]'>[COMMENT_URL]</a><br/><br/>[COMMENT_CONTENT]<br/><br/><a href='[UNSUBSCRIBE_URL]'>Unsubscribe</a>", "wpdiscuz")
I've also translated, in Loco, a few back-end lines, like "Welcome to wpDiscuz 7" title from wpDiscuz Dashboard, and they are all working fine, just as the front-end translations are, so it's not a "back-end" overall issue either, just the email notifications seem to have problems.
What else can I try? Ideas? π Thank you!
Let me check the actual entries in the database, and check a few things for wpDiscuz and Loco, maybe those are not updating properly or something... I'll get back to you in a few minutes.
I found where the issue is comming from. Btw, database tables and entries are all good.
The problem comes from the way wpDiscuz handles the user's languages, I didn't dig further into it yet (to check the code and such) but I think it's specific to how wpDiscuz handles the "same IP address" detection and how that relates to the user's languge. Let me explain what's happening:
- We have user Admin (administrator role), and we have user XVanish (Author role).
- Default WP language is set to Romanian. Admin's language is set to English (I can't stand seeing the back-end in a non-english language π ).
- XVanish has the language set to "Site Default", which is Romanian.
I'm using the Admin in Firefox to do back-end work, changes etc. I'm using XVanish in Chrome to post comments and to check XVanish's email address for the notifications.
Now:
- If I change XVanish's language from "Site Default" to English, nothing happents, I get the english email notification, as it should be. But if I change it to Romanian (not Site Default) I still get the english email notification.
- If I change Admin's language from English to Romanian OR Site Default (still Romanian) then I DO get the Romanian email notification that I've translated in Loco Translate.
- BUT Remember, I get the notifications for XVanish, that's the one I'm testing with from a different browser (Chrome or even Brave), and Admin is a different user with a different language option so it shouldn't affect XVanish's notifications.
So I think it's because wpDiscuz detects the same IP address for both users and since Admin has a higher role, it's sending the email translations based on the user language set for Admin, not for XVanish.
I hope you understand what's happening, if not fell free to ask questions.
What can we do to fix this? We need to be able to use at least 3 different users from the same location, 2 administrators and one author, 2 of them use Romanian ONLY and I use English so... this is a big issue for us. I also assume (not tested yet) that it's happening the same for all the other users that have the same IP address, maybe even for Guests, so what happents if they are in the same place using the same public IP address or network? This can create huge frustration and problems to visitors or customers.
Or maybe it's because I'm using wpDiscuz's AJAX and not the WP one... I'll test that as well.
Please let me know if you have a fix for this.
Thank you!
Or maybe it's because I'm using wpDiscuz's AJAX and not the WP one... I'll test that as well.
It's not, I've now tested with native WP AJAX and with wpDiscuz AJAX, I've also tested with wpDiscuz Cache disabled, tested with Combine and Minify JS/CSS disabled and a bunch of other settings that I thought could interfere, and of course I've also reset Phrases in between and enabled / disabled the use of .mo/.po files but still nothing...
And I also don't think it's an Akismet IP detection problem because it's doing the same with Akismet disabled, and I don't have any other comments related plugins or custom functions that use the IP detection or language management... and I've disabled all the cookies that could maybe conflict (like the GDPR acceptance cookie which is just a simple yes/no cookie) and still the issue persists... so It's either a wpDiscuz issue related to how it's managing same IP Address users OR maybe a native WP Comments / Discussion same IP one? What else could it be?
@asti I really need your help for this one... is this happening on a multi-language site as well? What if there are 10-20 people in the same room in a meeting and they don't speak english but the Admin in the room does? :))
What could I try next to get the proper language email notifications based on per user language selection? Or at least to enforce the default WP language for email notifications for all users BUT still using .mo/.po files? Even if it's a temporary fix untill you guys figure it out.
Thank you very much!
Another test:
Comment Form Settings > "Keep guest commenter credentials in browser cookies for X days" set to 0 (zero) in the hopes that wpDiscuz is getting some data from the browser / cookie or something, closed the browser, cleared cookies and cache several times, changed browser and all that... the issue still persists.
Maybe I'm looking in the wrong place, maybe it's a Loco translate issue... although I don;t really see how that could be if everything else is translating just fine, including wpDiscuz front and back-end... and Loco doesn't have any IP address feature and it's clearly an "same IP address" issue not just a translation one.
I've ran out of ideas... I'm taking a break until you brainstorm and reply, need to work on other things, this issue is taking too much of my time, although it's a big issue for multi-language sites if this is happening to everyone.