Localize custom form in wordpress / wpml
What I am trying to achive?
I have a feedback form which is handled by a java servlet. This servlet expects a parameter locale for the currently selected language (see code below at xxx somehow put the current language there xxx). We want to migrate our current system to Wordpress / wpml. We will probably need to adjust our servlet.
The example use case should go like this:
- open feedback form
- enter name/email/text
- submit
The code of the feedback form is as follows (and is embedded in the DIVI page as module code):
div class=form-contact
form id=feedback action=/feedback method=POST name=feedback
div class=row
div class=col-md-6
div class=row control-group
div class=form-group col-xs-12 controls
label for=nameName:/label
input id=name class=form-control name=authorName type=text /
/div
/div
/div
div class=col-md-6
div class=row control-group
div class=form-group col-xs-12 controls
label for=emailEmail*:/label
input id=email class=form-control name=email required= type=email /
/div
/div
/div
/div
div class=row control-group
div class=form-group col-xs-12 controls
label id=comment for=commentYour comment:/label
textarea class=form-control cols=60 name=comment required= rows=10/textarea
/div
/div
div class=required ( * fields are required)
/div
input name=locale type=hidden value=xxx somehow put the current language there xxx /
div id=success
/div
div class=row
div class=form-group col-xs-12
button class=btn btn-theme-bg btn-lg type=submit value=SendSend/button
/div
/div
/form
/div
Expected Result: The response page should display in the correct language
What are we currently using?
- Wordpress 5.8
- DIVI 4.9.4
- WPML 4.4.10
What did we already investigate
I have no idea how to get the currently selected language of Wordpress into the form parameter. I have the impression that I am asking a ridiculous question. Perhaps the way I want to resolve this issue is completely wrong.
A possible approach Perhaps I need to write in functions.php the value of ICL_LANGUAGE_CODE to a javascript object and use this in my custom form code on my Wordpress page? But this seems by far too complicated?
Topic plugin-wpml forms Wordpress
Category Web