6

There is a way to force the language of a contact created via webform: How to set a constant value for a field in webform (eg the prefered language)?

but I'd like to do it automatically, eg if I see the form as /fr/form it will set the preferred Civi language to fr, if the visitor is on /de/form it will be in german

Is this possible with webform civicrm?

0

This is only a partial answer - but the PHP $_SERVER global variable contain the requested language code (e.g. en_US) (See here). civicrm_option_value stores the "Languages" option group, which provides a mapping from the language code to the language option value ID.

It seems like you could parse the requested language (en and en-US must be mapped to en_US), add an API call to OptionValue.get to get the correct ID value, and set the default value for preferred language.

Note that this is slightly different from what you're requesting - a French-speaking user on an English-localised web browser will get English, not French - but the concept should be applicable.

  • in my experience, the requested language is not that reliable, eg. lots are having the en software, despite having a different language. but we can easily get the drupal language in php, so that would work too – Xavier Feb 25 '16 at 10:00
0

I think the best option is to add some jquery -> that reads the URL - parses it - and then writes to the appropriate field on the webform based on whether it finds /de/ , /fr/ or /en/

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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