Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client reported an issue where taxonomy terms such as 'Year' were not translating correctly on their vehicle listing page, despite having translations available. The default site language had been switched from English to Dutch, which seemed to affect the translation functionality.
Solution:
We identified that the issue was related to how the theme handled translations within specific PHP templates. To resolve this, we provided a code snippet to modify the theme's PHP file to ensure proper translation registration and application using WPML's hooks:

<?php<br />// WPML Workaround for compsupp-7432<br />if (class_exists('Sitepress')) {<br />    $textdomain = 'motors';<br />    $string_name = 'Motors - WPML String: '.substr($single_name, 0, 20);<br /><br />    if (apply_filters('wpml_default_language', NULL) == apply_filters('wpml_current_language', NULL)) {<br />        do_action('wpml_register_single_string', $textdomain, $string_name, $single_name);<br />    }<br />    // Apply the translation to the string<br />    $single_name = apply_filters('wpml_translate_single_string', $single_name, $textdomain, $string_name);<br />}<br /></code><br /><td class="t-label"> <?php echo esc_html($single_name); ?></td><br />After applying this change, the client was instructed to visit the page in the original language to register the string and then translate it via WPML > String Translator under the 'motors' textdomain.<br /><br />If this solution does not resolve your issue, or if it seems outdated or irrelevant to your case, we highly recommend opening a new support ticket. Additionally, please check related known issues at <a href="https://wpml.org/known-issues/">https://wpml.org/known-issues/</a>, verify the version of the permanent fix, and confirm that you have installed the latest versions of themes and plugins. For further assistance, you can also visit our support forum at <a href="https://wpml.org/forums/forum/english-support/">https://wpml.org/forums/forum/english-support/</a>.</td>

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.

Tagged: 

This topic contains 26 replies, has 3 voices.

Last updated by Carlos Rojas 3 months, 1 week ago.

Assisted by: Carlos Rojas.

Author Posts
June 16, 2024 at 9:38 am
June 16, 2024 at 9:39 am #15742367

stephanosP

Not sure if you received the private message?

June 16, 2024 at 9:42 am #15742368

stephanosP

FYI: The taxonomy "Motor" and "Aandrijving" (Drive) do translate like they are supposed to...

June 17, 2024 at 10:51 am #15744801

Paola Mendiburu
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Madrid (GMT+02:00)

Could you please go to the sandbox and translate all the listing categories?

So I can see if the issue is reproduced.

June 18, 2024 at 7:26 pm #15750703

stephanosP

Hi,

I just tested by translating "Mileage" and it does the exact same thing. I translated the taxonomy and all other strings but it does not translate it on the listing page.
I left "Engine" open so you can test yourself.

Kind regards

June 19, 2024 at 9:01 am #15754276

Paola Mendiburu
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Madrid (GMT+02:00)

Could you please confirm that the ones that doens´t appear translated are type numeric?

June 20, 2024 at 1:51 pm #15764239

stephanosP

I cannot open the sandbox anymore?

But no, it's also for other fields. The contents are not the issue, the content gets translated just fine, it's the label that's the issue.

June 21, 2024 at 7:50 am #15772036

Paola Mendiburu
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Madrid (GMT+02:00)

Ok thanks.

You can open the sandbox on hidden link

I will prepare it to send it to the compatibility team.

June 21, 2024 at 2:42 pm #15776256

Paola Mendiburu
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Madrid (GMT+02:00)

I have escalated to the compatibility team.

June 23, 2024 at 8:08 pm #15797535

stephanosP

Hi,

Any idea on how long this could take?

June 24, 2024 at 12:03 pm #15806703

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+02:00)

Hello,
My name is Carlos and I will continue with this ticket because my colleague Paola is on vacation.

We don't have an ETA for the ticket, but I will update you about its evolution.

Thank you very much for your patience and understanding!

June 26, 2024 at 6:16 am #15829899

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+02:00)

Hi there,

Please follow these steps to solve the issue:
- Create a full backup of the site
- Open the app/public/wp-content/plugins/motors-elementor-widgets/templates/widgets/single-listing/listing-data.php file
- Around line 91, look for the following snippet:

<td class="t-label"> <?php echo esc_html( $single_name ); ?></td>

- And replace with:

<?php
	// WPML Workaround for compsupp-7432
	if ( class_exists('Sitepress') ) {
		$textdomain = 'motors';
		$string_name = 'Motors - WPML String: '.substr($single_name, 0, 20);

		if ( apply_filters('wpml_default_language', NULL ) == apply_filters( 'wpml_current_language', NULL )) {
			do_action( 'wpml_register_single_string', $textdomain, $string_name, $single_name );
		}	
		// Apply the translation to the string
		$single_name = apply_filters('wpml_translate_single_string', $single_name , $textdomain, $string_name);
	}
?>

<td class="t-label"> <?php echo esc_html( $single_name ); ?></td>

- Visit the page with the issue in the original language, to register the string
- Go to WPML > String Translator and translate the string (under motors textdomain)

Can you confirm the issue is solved after following the steps described above?

June 26, 2024 at 10:01 am #15832300

stephanosP

Hi,

That seems to be working just fine! Thanks a lot.

One final thing, this also happens on the inventory page. There it shows the same data, but those are not translated either. What would the fix for that one be?

June 26, 2024 at 12:18 pm #15833684

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+02:00)

Could you share the URL of the inventory page?

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.