cf_translate_get_current_language

Green mountains

The filter cf_translate_get_current_language is used by the Caldera Forms Translations add-on to set the language of the form. This is handled automatically in many ways, see the getting started guide for more information. You can use this filter to change the current language based on some other value.

Important: The default logic for switching languages — including switching based on WPML settings, happens on this hook with priority 10. That is why all examples here use priority 15 — so they override default logic.

Use Root (non-local) 2 Letter Language Codes

These examples show how to remove local version of a language, for example changing, “es_US” to “es”.

Using An Alternative Query Variable For Language Switching

 

Where Does This Code Go?

When using WordPress hooks to customize Caldera Forms or other plugins you should not modify the plugin files, or you will lose your changes when you update the plugin. Instead you should create a small plugin to hold the custom code. It's easy, learn how here.

Technically you can add the custom code to your theme's functions.php, but then you will not be able to change your theme and keep these customizations.

Learn More