liedekef / events-made-easy

The wordpress/classicpress plugin events-made-easy to manage events, memberships and more.
https://www.e-dynamics.be/wordpress
GNU General Public License v2.0
26 stars 5 forks source link

‘Contact Person Booking Made Email Body & Subject' not translating to other languages #60

Closed refugeindhamma closed 1 year ago

refugeindhamma commented 1 year ago

Describe the bug Multi-language tags in ‘Contact Person Booking Made Email Body & Subject' template not translating for Chinese. Subject: image

Body: image

To Reproduce Steps to reproduce the behavior:

  1. Add language tags to ‘Contact Person Booking Made Email Body & Subject' template
  2. Register for event in Chinese language
  3. See error

Expected behavior Email should display the Chinese language for all items.

Template Subject Template:

[:en]New registration for 'Equanimity Hybrid Course'[:zh]'平常心混合课程' 的新预订[:]

Body Template:

[:en]
#_PERSONFULLNAME (#_PERSONEMAIL) wants to register #_MULTIBOOKING_SEATS seat(s) for 'Equanimity Hybrid Course'.
<BR /><BR />
The details are as follows:
<BR />
#_MULTIBOOKING_DETAILS_TEMPLATE{36}
<BR /><BR />
Now the following seats are still available:
#_MULTIBOOKING_DETAILS_TEMPLATE{38}
<BR /><BR />
With Metta,
Events Manager
[:zh]
#_PERSONFULLNAME(#_PERSONEMAIL)将在 ‘平常心混合课程’ 预订 #_MULTIBOOKING_SEATS 个座位。
<BR /><BR />
详情如下:
<BR />
#_MULTIBOOKING_DETAILS_TEMPLATE{36}
<BR /><BR />
座位空缺如下:
#_MULTIBOOKING_DETAILS_TEMPLATE{38}
<BR /><BR />
祝安康快乐,
活动经理
[:]
liedekef commented 1 year ago

Just tested it here: added the language tags and changed my site to chinese. Resulting booking mails were as expected in Chinese ...

refugeindhamma commented 1 year ago

I tested it multiple times today and all my contact person emails are in English. I don't think something's wrong with Polylang + Loco because the registrant received all the emails in Chinese.

Registrant's emails: image

Contact person's emails: image

Booking Cancelled Email Subject:

[:en]Registration for '#_EVENTNAME' cancelled[:zh]取消了 "#_EVENTNAME" 的预订[:]

Booking Cancelled Email Body:

[:en]
Dear #_PERSONFULLNAME,

Your request to register #_RESPSEATS seat(s) for #_EVENTNAME has been cancelled.

With Metta,
#_CONTACTPERSON

[:zh]
亲爱的 #_PERSONFULLNAME,

你为 #_EVENTNAME 预订的 #_RESPSEATS 个座位的请求已被取消。

祝安康快乐, 
#_CONTACTPERSON
[:]

Contact Person Cancelled Booking Email Subject:

[:en]A registration has been cancelled for '#_EVENTNAME'[:zh]已取消 '#_EVENTNAME' 的预订[:]

Contact Person Cancelled Booking Email Body:

[:en]
#_PERSONFULLNAME (#_PERSONEMAIL) has cancelled for #_EVENTNAME on #_STARTDATE.
Now there are #_RESERVEDSEATS seat(s) registered, #_AVAILABLESEATS are still available.

With Metta,
Events Manager

[:zh]
#_PERSONFULLNAME(#_PERSONEMAIL)已经取消了 #_STARTDATE 的#_EVENTNAME。

现在有 #_RESERVEDSEATS 个座位被预订,仍有 #_AVAILABLESEATS 个座位可用。

祝安康快乐, 
活动经理
[:]

My templates also seem to be right.

What other settings, other than templates, can I check for proper translations?

Edit: The confirmation message is also not being translated. image

The message is already translated in Glotpress. image

Edit 2: Cancellation messages are translated though. But the date is not translated. 'March' should be translated to '3月‘ and the date format to Y F j. Cancellation confirmation: image

Cancellation confirmed: image

liedekef commented 1 year ago

Translation of dates is done through php, not EME. But I think something else is wrong ... this message is clearly translated in EME:

$ret_string .= "<div class='eme-message-success eme-rsvp-message-success'>" . __( 'Thank you for confirming these bookings.', 'events-made-easy' ) . '</div>';

So if that translation is not coming through, something else is not working as expected (not EME). So several questions:

What are your polylang url settings? See: image

liedekef commented 1 year ago

And since polylang seems extremely complicated to me, can you put up a test website (not live) and provide me with an account to test? Also: make sure you can reproduce the problem on the test site and provide the simplest scenario for me to test.

refugeindhamma commented 1 year ago

1) This is from Polylang:

The language is either set by the language code in URL, or you can use a different sub-domain or domain per language.

My registration forms are 2 different posts with one set to English and the other set to Chinese. There is also a setting to link these 2 posts together. To switch languages, there is a widget at the top right hand corner to do so.

You can go to my test website/web page to see the registration forms.

2) I mean the plugin's translation handled by Wordpress. Not sure what it's called. I see the names "Polyglot", "Glotpress" in the documentation.

3) Polylang's URL settings image

Edit: 4) Sent the link to your email. You can use the posts mentioned above to do your testing. It should be the first 2 posts in "All Posts". The 4 recurrent events shown in EME are the ones I am using for the registration forms for both languages.

liedekef commented 1 year ago

Currently (see mail), I think it is related to the polylang-language set for the special events page. I now removed that language, causing the page to be in the language of choice (and not the per-page set language). Feel free to provide feedback.

refugeindhamma commented 1 year ago

I'm having problems with my email provider. Their webmail server is taking very long to load so I can't access the emails sent from the test server. I will update once their server is back to normal.

liedekef commented 1 year ago

you can also look in the EME email-management menu, tab "sent emails", all emails from EME are kept there. I do see that there are translation tags around the person name (in that tab), how/why did you do that?

liedekef commented 1 year ago

btw: I clicked on a link in the mail (assuming it is unsubscribe/confirm or so) and got a bunch of chinese characters back, so it seems ok for me :-)

refugeindhamma commented 1 year ago

you can also look in the EME email-management menu, tab "sent emails", all emails from EME are kept there. I do see that there are translation tags around the person name (in that tab), how/why did you do that?

It's because Chinese names are in the format LASTNAME + FIRSTNAME, whereas for English names, it is in the format FIRSTNAME + LASTNAME.

refugeindhamma commented 1 year ago

It is working now! Thanks so much! image

Any changes in code to prevent this from happening again?

Edit: I now removed that language, causing the page to be in the language of choice (and not the per-page set language). Feel free to provide feedback. Is this a change in EME code?

liedekef commented 1 year ago

In fact this is not an EME issue but an polylang issue. As I said in my mail:

The actual problem is that the special events page is "linked" to english. Best to do here:

- delete the special events page
- disable polylang
- create new events page
- enable polylang
- set the new page in the EME options (Events tab) settings

Since the page is then not linked to a language, it should use the language of choice at that moment.

Also: I went a little further and added code to EME that will remove the polylang language if set to it. So that should solve it for future cases :-) . In theory polylang should just provide an option to remove the language for specific pages, as I can't start including code for each translation plugin myself. In that case, the workaround as above is also ok. However: it might be that one needs to refresh the rewrite rules if the language ever gets added again, we'll see that when it happens again.

liedekef commented 1 year ago

The code will be in the next version of EME (and is on your dev-site). Now: does this mean that the name translation is incorrect, or just stored/displayed wrong in EME "sent email" tab?

liedekef commented 1 year ago

And while I'm at it, this info on polylang was already in the plugin compatibility document: https://www.e-dynamics.be/wordpress/compatibility-with-other-plugins/ That would've saved us some time ... :-)

refugeindhamma commented 1 year ago

I will report this issue to Polylang and see if they can do anything about it.

refugeindhamma commented 1 year ago

The code will be in the next version of EME (and is on your dev-site). Now: does this mean that the name translation is incorrect, or just stored/displayed wrong in EME "sent email" tab?

In the "Email Templates" Settings, if I do not use the language tags and using First + Last: image

The email I receive will also be First + Last: image

But if I put the language tags like this: image

Then, the name for Chinese can be displayed correctly, i.e. Last + First: image

Is this what you are asking?

Edit: This is from "Sent Emails": Screenshot 2023-02-07 at 08-52-45 Email management ‹ Refuge In Dhamma — WordPress

Do you mean that in "Sent Emails", the name should be displayed in the Chinese format, instead of current form with language tags? It has been like this ever since I started using EME so I didn't give it much thought.

liedekef commented 1 year ago

It is indeed from "Set emails". I've fixed the code now for all usage of the full name. Next version will fix that :-) Now the gdpr issue ...