0

We're trying to work out the best way to get Freeform to send notifications in the user's language. For example, our contact form is on a page where the first segment is the lang code (/en/, /de/, etc.). We've set the config lang to match the lang set in the URL.

Any ideas on how to accomplish this?

Thanks, Paul

2

Let's take the user_notification_template="" parameter as an example, and your two languages: en and de. (This would work for admin_notification_template="" and recipient_user_template="" as well)

First, create two notification templates in Freeform (Notifications tab in the Freeform CP), one in each language. Let's call their short names user_email_en and user_email_de.

Then in your template, in either {exp:freeform:form} or {exp:freeform:composer} tags (whatever one you are using), add the user_notification_template="" parameter, with an early-parsed conditional as its value. Here are a few different ways you would use the parameter:

user_notification_template="{if segment_1 == 'en'}user_email_en{/if}{if segment_1 == 'de'}user_email_de{/if}
user_notification_template="{if segment_1}user_email_{segment_1}{/if}"

If you registered an early global variable in index.php (eg. {country_code}), you could do the same as the above, but with that variable. Eg.

user_notification_template="{if country_code == 'en'}user_email_en{/if}{if country_code == 'de'}user_email_de{/if}
user_notification_template="{if country_code}user_email_{country_code}{/if}"
user_notification_template="user_email_{country_code}"

NOTE: Please make sure to use an early-parsed conditional and NOT an advanced conditional (eg. containing {if:else} or {if:elseif}, using AND/OR operators, etc). Only early-parsed conditionals can work in parameters. Please refer to the EE documentation about parse order for more details.

2
  • I don't know why I thought we could only assign notification template via the CP. Works perfectly for us as now, thanks!
    – Paul
    Mar 8 '14 at 14:49
  • You can indeed set notification templates in the CP, but you can override the setting by using the corresponding parameter in the template for {exp:freeform:form} or {exp:freeform:composer}. Glad the solution worked. :)
    – Solspace
    Mar 10 '14 at 1:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.