Skip Navigation

Open

Topic Tags: Compatibility

Overview of the issue

Ninja Forms has a new feature called Repeatable Fields. This feature is not yet available for translation in our Advanced Translations Editor. However, we are planning to make it compatible soon.

Workaround

  • Please, make a full backup of you site before proceeding.
  • Now that you have your backup ready, we need to modify 2 files:
  • Open /wp-content/plugins/wpml-ninja-forms/classes/Hooks/NinjaForms/Strings.php.
  • Look for the line 76:
    $package->registerField( $field->get_id(), $field->get_settings() );
    
  • And just after add:
    				// Register repeater fields strings
    				if ( 'repeater' === $field->get_settings( 'type' ) && $field->get_settings()['fields'] ) {
    					foreach ( $field->get_settings()['fields'] as $subfield) {
    						$package->registerField( $subfield['id'], $subfield );
    					}
    
    				}
    
  • Then open /wp-content/plugins/wpml-ninja-forms/vendor/wpml/forms/classes/Translation/Package.php.
  • Look for the line 314:
    return $data;
  • And just before add:
    		// Translate repeater fields strings
    		if ( $data['fields'] ) {
    			foreach ( $data['fields'] as $key => $field ) {
    				$forTranslation = $this->fieldProperties->forTranslation( $field );
    				foreach ( $forTranslation as $propertyName => $translationSettings ) {
    					$stringValue = $this->fieldProperties->getValue( $field, $propertyName );
    					if ( $stringValue ) {
    						if ( $this->isArray( $stringValue, $translationSettings ) ) {
    							$field[ $propertyName ] = $this->translateOptions(
    								$stringValue,
    								$field['id'],
    								$translationSettings
    							);
    						} else {
    							$data['fields'][$key][$propertyName] = $this->translateString(
    								$stringValue,
    								$field['id'],
    								$propertyName
    							);
    						}
    					}
    				}
    			}
    		}
    

Next steps to resolve this issue

We will get this issue resolved in the next version of Ninja Forms Multilingual.

Leave a Reply

Please leave here comments about this page only.
For technical support and feature suggestions, head to our forum. We are waiting there!

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>