/** * Create a map for your custom field labels to be translated. * Set a new case for each language locale following the * example set below. Each case should be an array where * the array key is the field's meta key and the value is * the translated text for that locale. * * Follow the example below where each array element is as follows: * * 'the_meta_key' => 'The translated value for the requested locale', * * The default value will simply return an empty array. */ function my_custom_translation_strings( $locale ) { switch ( $locale ) { case "de_DE": $string_map = array( 'custom_field' => 'Benutzerdefinierte Feld', 'other_custom_field' => 'Anderes benutzerdefiniertes Feld', ); break; case "es_ES": $string_map = array( 'custom_field' => 'Campo personalizado', 'other_custom_field' => 'Otro campo personalizado', ); break; default: $string_map = array(); break; } return $string_map; } /** * This will filter the register form labels and input tag * placeholders based on the translation string map returned * for the requested locale. * * No changes are necessary to this filter. */ add_filter( 'wpmem_register_form_rows', 'apply_my_custom_translation' ); function apply_my_custom_translation( $rows ) { global $wpmem; $string_map = my_custom_translation_strings( get_locale() ); if ( ! empty( $string_map ) ) { foreach ( $rows as $meta_key => $row ) { if ( array_key_exists( $meta_key, $string_map ) ) { $rows[ $meta_key ]['label'] = str_replace( $row['label_text'], $string_map[ $meta_key ], $row['label'] ); $rows[ $meta_key ]['field'] = str_replace( 'placeholder="' . $wpmem->fields[ $meta_key ]['placeholder'] . '"', 'placeholder="' . $string_map[ $meta_key ] . '"', $row['field'] ); } } } return $rows; } /** * Other filters may be used and or necessary depending on * actual application. This example just covers applying * additional translation to the register form labels. * Messages, dialogs, login form, widget, those would all * be separate filters. Note that you do only need to create * one single mapping function and you can use that fof * all of your translation filters. */
Not sure what to do with this code?
You're not a "coder" and don't know what to do? Don't worry! Code Snippets are the basic building blocks of WordPress customization, and once you know the basics, they are simple to use.
Here are some free articles to get you started:
- Using Code Snippets from the Site
- Using a code snippets plugin
- The functions.php File
- Create a plugin file for custom functions
- Create a child theme
- Do not modify plugin files!
For "hands on" help, consider a plugin support subscription or the Pro Bundle.