# Freeform, Structure, Transcribe and Freebie - how to return to correct language on contact form

I have an English site that uses Structure and Transcribe. The 2 language translations, French and German, are about to go live except for one little issue. On one page I have a contact form using Freeform Pro that also contains the 'Thank you' text that is shown once the form has been submitted, using a Freebie tag. It has been working fine for the English (default) version of the site. The form goes from www.mysite.com/contact-us to www.mysite.com/contact-us/thanks once the form is submitted.

The code I've used. is below:

                {if freebie_last == "thanks"}
<p>{contact_thanks}</p>
{if:else}
{contact_info}

{exp:freeform:form
form_id="1"
required="name|email|country|area_of_interest|user_enquiry"
return="{segment_1}/thanks"
inline_errors="yes"
form:class="well"
}


Unfortunately I can't work out how to get the translations to show the correct 'Thank you' page. When I'm on www.mysite.com/de/kontakt and hit Submit I am taken to the 404 page because it's trying to direct to www.mysite.com/kontakt/thanks. It should be www.mysite.com/de/kontakt/thanks - it's not including the 'de' segment of the url.

I've tried several variations of the return path but none seem to direct me to www.mysite.com/de/kontakt/thanks. The language segment is always being removed, but I need to keep the return="{segment_1}/thanks for the English version of the site to work. I was thinking an {if} statement would be needed but nothing seems to be working.

I've tried:

                        {if '{transcribe:language_abbreviation}' == 'de'}
return="{freebie_1}/{freebie_2}/thanks"
{if:else}
return="{segment_1}/thanks"
{/if}


or:

                        {if '{transcribe:language_abbreviation}' == 'de'}
return="{segment_1}/{segment_2}/thanks"
{if:else}
return="{segment_1}/thanks"
{/if}


Does {if:else} not work here? If not, what does? Or am I going about this in totally the wrong way by using Freebie (I'm a bit unsure how it works). I've tried adding fr|de to the breaking segments to no avail.

Any help would be appreciated. Thanks

You can simply make entries for the return pages, and have transcribe handle it for you.

What i do is to embed the form: {embed="_inc/.contact_form" thepath="{exp:transcribe:uri path='/contact/thank-you/'}"}

{exp:forms_js_validation:init lang="{transcribe:language_abbreviation}"}
selector="form"
require_class="required"
email_class="require_email
}
{exp:freeform:form
form:id="2"
form:class="custom"
form_name="more_info"
return="{embed:thepath}"
}
{/exp:freeform:form}

• Thank you Jelle, this worked for me (after a lot of trial and error with me trying to working out the correct path!). A quick question. I use inline errors but the language output is always English (even in the other translations). If you use Forms JS Validation with the lang variable does this make the errors output in the correct language? Or is there a way to make inline errors output in the correct language? Again, thank you so much. – Mosaik Aug 22 '14 at 21:24
• sorry i didn't reply earlier. however, bij using this setup you can indeed get the error messages outputted in the correct language – Jelle Dijkstra Aug 27 '14 at 11:01

An {if:else} conditional won't work here (or with any other tag to try to change a parameter) because it's parsed after {exp:...} tags. This is often called an advanced conditional. You can see this by turning on Template Debugging: the parameters should look unparsed or partially parsed for the tag.

I don't have experience with Transcribe, Structure and Freebie, but if de/fr/en are considered URL segments (i.e. {segment_1} is de, fr, or en, for example), then you could use simple conditionals, which parse before {exp:...} tags, to control parameters. Eg.

return="{if segment_1 == "de"}/de/kontakt/thanks{/if}{if segment_1 == "fr"}/de/contact/thanks{/if}{if segment_1 == "en"}/contact/thanks{/if}"


Note: {if:else} and conditionals containing &&, ||, AND, OR are considered advanced conditionals and wouldn't work.

Alternatively, you could wrap the whole Freeform code in whatever Transcribe/Structure/Freebie conditionals/tags you want. This would repeat a lot of the same code multiple times, but would also get around your problem.

• as far as i can remember, the language segments are not seen by EE as url segments – Jelle Dijkstra Aug 15 '14 at 11:46
• {segment} doesn't appear to work but you can do: return="{if '{transcribe:language_abbreviation}' == "en"}/en/contact-us/thank-you{/if}{if '{transcribe:language_abbreviation}' == "es"}/es/contacto/gracias{/if}" – Mel Aug 11 '15 at 19:35