Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 19 replies, has 2 voices.

Last updated by Osama Mersal 3 weeks, 4 days ago.

Assigned support staff: Osama Mersal.

Author Posts
September 21, 2021 at 1:23 pm #9628723

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for your patience. I've just received our 2nd tier supporters' reply.

In order to translate these fields, kindly check the following steps.
1- Edit the file (wp-content/plugins/wpml-ninja-forms/classes/Hooks/NinjaForms/Strings.php) after line 76

$package->registerField( $field->get_id(), $field->get_settings() );

Kindly add the following code:

// 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 );
					}
				}

2- Edit the file (wp-content/plugins/wpml-ninja-forms/vendor/wpml/forms/classes/Translation/Package.php) before line 290

return $data;

Add the following code.

// 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
							);
						}
					}
				}
			}
		}

3- Update the original form
4- Update the translation

I've applied these steps on the sandbox site, and it worked correctly. Kindly check this page. (hidden link)

Would you please try these steps on your site and let me know if that fixed the issue?

Thanks,
Osama

September 22, 2021 at 4:52 pm #9639859

shaneB-8

Hooray! This works excellent thank you!! Will these changes make it in the next Ninja Forms WPML release? Just want to make sure how to handle ensuring that they don't get nuked.

THANKS so much!

September 22, 2021 at 4:56 pm #9639917

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

It's great to hear that's working now. I'm not sure if it will be in the next release, but our dev will work on these changes in order to be safe; after the next update, check the files and check if the changes are applied.

Have a nice day!

Regards,
Osama

September 22, 2021 at 4:59 pm #9639921

shaneB-8

My issue is resolved now. Thank you! If you could delete the backup that would be fantastic!

September 24, 2021 at 2:03 pm #9655387

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

I've deleted your sit's copy. Here is the workaround if you need it again. (https://wpml.org/errata/ninja-forms-repeater-fields-not-available-in-the-translation-editor/)

Have a good day!

Regards,
Osama