I'm using a form using Sprout Forms plugin. This form is set for submitting via AJAX. The documentation explains how to translate error message, but this is not working via AJAX submissions.

Currently, the primary language of this website is French. While the site is browsed in English or Dutch, it still shows AJAX errors in French.

How can I get Sprout Forms errors in current language using AJAX?

1 Answer 1


The AJAX POST url variable (postUrl) should be set from the form template with this Twig code:

<script type="text/javascript">
    var postUrl;
    if ('{{ craft.i18n.getCurrentLocale() }}' == '{{ craft.i18n.getPrimarySiteLocale() }}') {
        postUrl = '/';
    } else {
        postUrl = '/{{ craft.i18n.getCurrentLocale() }}/';

Furthermore, an hidden field should be added in order to call the Sprout Forms' controller on submit:

<input type="hidden" name="action" value="sproutForms/entries/saveEntry">

This submits the form in the current locale, and returns errors in this same locale.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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