Hi again,
another trouble disclosed.

In my webform I have e-mail custom template with HTML tags.

When user sent form in original language = e-mail body is OK (formated as HTML).
If user sent form in another language = text of message is translated, but e-mail body is formated as plain text, without HTML tags (template is translated with HTML tags).

CommentFileSizeAuthor
#53 webform_translated_email_body_sent_as_plain_text--2633966--53.patch3.98 KBdom.
#49 webform_localization-_PLAIN_TEXT_WORKAROUND_translated_email_body_sent_as_plain_text-2633966-49.patch4.65 KBjoseph.olstad
#48 webform_localization-_PLAIN_TEXT_WORKAROUND_translated_email_body_sent_as_plain_text-2633966-48.patch4.66 KBjoseph.olstad
#45 user_notofication.txt1.43 KBDandys
#45 admin_notification.txt1.45 KBDandys
#34 webform_03_de_patch_30.png20.61 KBDandys
#30 webform_localization-translated_email_body_sent_as_plain_text-2633966-30.patch5.95 KBjoseph.olstad
#29 webform_03_de_patch_27.png12.86 KBDandys
#26 webform_localization-translated_email_body_sent_as_plain_text-2633966-27.patch4.83 KBjoseph.olstad
#25 webform_localization-translated_email_body_sent_as_plain_text-2633966-25.patch4.85 KBjoseph.olstad
#22 webform_localization-translated_email_body_sent_as_plain_text-2633966-18.patch4.78 KBjoseph.olstad
#20 webform_03_de_patch_16.png17.74 KBDandys
#16 webform_localization-translated_email_body_sent_as_plain_text-2633966-16.patch4.6 KBjoseph.olstad
#14 webform_localization-translated_email_body_sent_as_plain_text-2633966-14.patch4.05 KBjoseph.olstad
#12 webform_localization-translated_email_body_sent_as_plain_text-2633966-12.patch4.28 KBjoseph.olstad
#3 webform_localization-translated_email_body_sent_as_plain_text-2633966-3.patch1.26 KBjoseph.olstad
#5 webform_localization-translated_email_body_sent_as_plain_text-2633966-5.patch3.75 KBjoseph.olstad
#7 webform_localization-translated_email_body_sent_as_plain_text-2633966-99.patch3.67 KBjoseph.olstad
#11 webform_02_de_patch.png61.89 KBDandys
#11 webform_02_de_no_patch.png35.26 KBDandys
#11 webform_02_en.png39.04 KBDandys

Comments

Dandys created an issue. See original summary.

joseph.olstad’s picture

Patch to follow shortly, after dentist drills my teeth

joseph.olstad’s picture

joseph.olstad’s picture

Hi Daddys, can you please confirm that patch #3 solves this issue? I will give you credit for this one.

joseph.olstad’s picture

This patch reverts commit 8058b74

Status: Needs review » Needs work
joseph.olstad’s picture

Status: Needs work » Needs review
StatusFileSize
new3.67 KB
joseph.olstad’s picture

patch #7 I should have called 7 not 99..
This patch is to revert commit 8058b74 ( "Wrong or missing 'format' parameters in most i18n_string() calls"

joseph.olstad’s picture

Dandys , could you please try patch #3 and see if that does the trick for you?

joseph.olstad’s picture

if not , try patch #99 , these will apply to the latest dev branch

here's an instruction on how to use patch
wget can help you download the patch.

cd /path/to/webform_localization
wget https://www.drupal.org/files/issues/webform_localization-translated_emai...
#TEST THE PATCH
patch --dry-run -p1 < webform_localization-translated_email_body_sent_as_plain_text-2633966-3.patch

#output will say, check ...
#IF no failures, then apply the patch for real
patch -p1 < webform_localization-translated_email_body_sent_as_plain_text-2633966-3.patch

To reverse a patch use the same command but with the "-R" flag
so
test it first with the --dry-run flag
patch -R --dry-run -p1 < webform_localization-translated_email_body_sent_as_plain_text-2633966-3.patch

#no fails, then to reverse it for real do same thing without --dry-run
patch -R -p1 < webform_localization-translated_email_body_sent_as_plain_text-2633966-3.patch

If you are on windows, you can download patch.exe
otherwise on Linux I believe the patch program is installed by default on most distros

Dandys’s picture

StatusFileSize
new39.04 KB
new35.26 KB
new61.89 KB

I checked the operation of both patches, but effect of their actions is exactly the same (see attached images).

joseph.olstad’s picture

Hi Dandys, your feedback is invaluable, thanks again. Based on those results I think this patch could be the winner if it passes simpletest first.

You may have to re-enter the missing html into the translation again.

See related issue and the new patch, you'll have to reverse the other patch first before applying this one.

Status: Needs review » Needs work
joseph.olstad’s picture

Status: Needs work » Needs review
StatusFileSize
new4.05 KB

ok, try this instead.

Status: Needs review » Needs work
joseph.olstad’s picture

Status: Needs work » Needs review
StatusFileSize
new4.6 KB

New patch

joseph.olstad’s picture

I'm hoping that I18N_STRING_FILTER_XSS_ADMIN is sufficient for your html, otherwise if I put the option array(sanitise =­> 'TRUE') without specifying format the default kicks in and will be even more permissive and should allow all your html

If your test doesn't work with patch 15 then we may need to try array(sanitise =­> 'TRUE')
instead of array(format => I18N_STRING_FILTER_XSS)

SEE api documentation for more details:
http://www.drupalcontrib.org/api/drupal/contributions%21i18n%21i18n_stri...

joseph.olstad’s picture

Dandys, during the test, you may need to double check the translation to make sure the required html tags are put back in prior to new test.

joseph.olstad’s picture

I'll write another patch for the other option.

Dandys’s picture

StatusFileSize
new17.74 KB

Hi @joseph.olstad

Now we have something new:
- message contains HTML elements
- lost some labels and field values

Dandys’s picture

Hi @joseph.olstad

Now we have something new:
- message contains HTML elements
- lost some labels and field values

joseph.olstad’s picture

ok, see if this patch passes testing.

joseph.olstad’s picture

this patch (should) sanitize with default and keep all valid html , I hope

joseph.olstad’s picture

sorry, no that patch won't , I will put a new patch

joseph.olstad’s picture

joseph.olstad’s picture

joseph.olstad’s picture

wait for test results, try #27 if its passing

Dandys’s picture

StatusFileSize
new12.86 KB

Result: form elements without HTML tags.

joseph.olstad’s picture

joseph.olstad’s picture

Patch #30 if there's no format set I'm fallbacking to I18N_STRING_FILTER_XSS_ADMIN

if this doesn't work then maybe force 'full_html'

joseph.olstad’s picture

Hi Dandys, sorry for the trouble, can you please test this one more time? I think we're close.

joseph.olstad’s picture

You might need to re-translate again the text with the html tags, I hope you have it copy paste.

Dandys’s picture

StatusFileSize
new20.61 KB

After applying patch #30, we get the result the same as for #16.

Dandys’s picture

After applying patch #30, we get the result the same as for #16.

joseph.olstad’s picture

Hi Dandys, yes I also got that result with patch 30..... Ok, back to the drawing board. I'll write a new patch.

joseph.olstad’s picture

Hi Dandys, can you retry patch 30 , but first go to admin settings:

/admin/config/regional/i18n/strings
Under 'translatable text formats'
make sure to add a checkmark to 'Full HTML' and 'Filtered HTML'

joseph.olstad’s picture

Priority: Normal » Critical

Needs work, just cant seem to get i18n_string filter right. see thread above.

joseph.olstad’s picture

Status: Needs review » Needs work
joseph.olstad’s picture

Assigned: Unassigned » joel_osc

joel_osc , can you please lend a helping hand and weigh into this? what filter format should we be using?

see :
Translatable text formats
Filtered HTML
Full HTML
Plain text

/admin/config/regional/i18n/strings
Under 'translatable text formats'
make sure to add a checkmark to 'Full HTML' and 'Filtered HTML'

and see api (contrib api for i18n_string_format)
http://www.drupalcontrib.org/api/drupal/contributions%21i18n%21i18n_stri...

joseph.olstad’s picture

We need some help with this.

joseph.olstad’s picture

Patch #16 is the closest we get, but has issues.

Original english language:
screenshot0

Deutch translation without patch:
screenshot01

Deutch translation with patch 16
Some missing fields
screenshot1

joseph.olstad’s picture

joel_osc, if you can weigh into this, maybe your eyes will help.

Right now I am burnt up on this and my kids are running wild.

joseph.olstad’s picture

Dandys, can you please send me your untranslated email template in a .txt file so I can have a look at what is in it? I assume you're using tokens? I'll try to reproduce your configuration in my test environment.

Dandys’s picture

StatusFileSize
new1.45 KB
new1.43 KB

Hi, @joseph.olstad

Of course, that's no problem. See attachments.

joseph.olstad’s picture

Hi Dandys and Joel_osc, ok, I am still working on this issue, however it looks like there may be a workaround.

see this comment:

https://www.drupal.org/node/2356791#comment-9415815

if we change the i18n_string filter to 'plain_text' , then write a tpl that decodes the html entities, this will render the html in the original format without losing stuff.

it would have to be a combination of a patch and a tpl, however I'm currently looking to see if there isn't another way to do this, maybe if needed hit the database directly and force html

https://www.drupal.org/node/2356791#comment-9415815

May have to change all I18N_STRING_FILTER_XSS to 'plain_text' , then apply workaround tpl with decode html

but looking for a better way.

Joel_osc, let me know if you have any thoughts.

joseph.olstad’s picture

Mschudders workaround was done prior to putting the I18N_STRING_FILTER_XSS in, so we may have to remove those, and then come up with a better workaround solution , ideally this should all be handled by webform_localization

we could add a special webform tpl I suppose, I'd like to hear from joel_osc see what he has to say.

joseph.olstad’s picture

see comment #46 , this patch (if passes) should not sanitize any i18n_strings , but to render the output as html a tpl MAY need to be created and call html decode function to render it in html

currently testing a few things until we can find a better solution.

joseph.olstad’s picture

oops, meant to have all at 'plain_text' one small change to this patch compared to 48 (plain_text or sanitize FALSE)

joseph.olstad’s picture

Hmm, looks like the simpletest bot isn't running through all 2000+ tests, must be due to changes on d.o

joseph.olstad’s picture

Status: Needs review » Needs work

see comment #46 and patch #49 , this is a workaround, I'm not satisfied with the workaround however its the best solution until we come up with a full solution in the module.

Mixologic’s picture

Testing is working as designed: see: https://www.drupal.org/node/2638832#comment-10731048

dom.’s picture

Status: Needs work » Needs review
StatusFileSize
new3.98 KB

Patch #49 gives me wired results where select components :
1- on webform display have <p></p> around their translated value when used as list (but not as checkboxes)
2- does not render at all on display (neither in submission page or when used with tokens)
The changes in patch attached seems to make the deal for me.

joseph.olstad’s picture

Hi Dom. , thanks for the patch, I have not yet had time to review it however perhaps Dandys would be able to review it for us? Dandys, would you be able to re-test your use case with the latest patch that Dom. submitted, you'll probably have to apply the patch, refresh the translation strings and retranslate and see what gets rendered on the other languages. If you can test this out that'd be really appreciated as I did do a lot of work and testing to get this far already , Dom. says his patch is working for him. From what I read about this issue and related issues is that perhaps a custom filter may have to be added , perhaps Dom. can elaborate on his use case and test environment.

Dandys’s picture

Hi @joseph.olstad and @Dom.

Recently I could not work on the project but now I came back.
Thanks for last patch #53 - works perfectly! Great job!

joseph.olstad’s picture

ok lets commit patch #53 asap.

joseph.olstad’s picture

Thanks Dom and Dandys, I'll give some commit credit to you both (and me too)

joseph.olstad’s picture

Assigned: joel_osc » joseph.olstad
Status: Needs review » Fixed

  • joseph.olstad committed 4470357 on 7.x-4.x authored by Dom.
    Issue #2633966 by joseph.olstad, Dom., Dandys: Translated e-mail body...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.