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
May 29, 2024 at 2:23 pm

stephanosP

For example KILOMETERSTAND

hidden link

May 29, 2024 at 3:13 pm
May 29, 2024 at 3:16 pm #15684710

Paola Mendiburu
Supporter

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

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

Could you please install the theme in the following test site?
hidden link

Then create KILOMETERSTAND option and create a car.

Please let me know when you have set up so I can see if I can translate it correctly.

May 30, 2024 at 9:33 am #15686970

stephanosP

Your colleague did install a plugin to create a copy a while ago. Is this something you can do? Makes it easier to have the same setup.

One thing to note is that the default language in the past was "English", and this was changed to Dutch. We'd need to keep it in Dutch, as our main customers are Dutch, but is there a way to set the default to English but simply redirect to Dutch if the site opens?

May 31, 2024 at 7:50 am #15690888

Paola Mendiburu
Supporter

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

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

The thing is that we will need to replicate the problem to see if it is a compatibility issue.

Please install the theme in the test site so we can try to reproduce the issue:
hidden link

June 9, 2024 at 8:57 pm #15719835

stephanosP

Hi, I'm sorry for the late respons. Was ill and didn't have the chance to do so.

I just noticed the sandbox has expired. Could you reopen it please?

June 10, 2024 at 7:42 am #15720445

Paola Mendiburu
Supporter

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

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

I have created a new one:
hidden link

Please let me know when it is done.

June 10, 2024 at 12:32 pm #15721996

stephanosP

Hi, I've installed the theme & plugins that come with it. There is an issue with importing demo data which gives me a 504 error but it seems enough data is imported.
Menu looks a bit weird but that's ok.

What I've done is gone to "Inventory" and tested with the "Tesla Roadster 2021" listing. I've made the necessary actions in WPML so that taxonomies are being translated and I've also translated that particular listing (just copied content) to Dutch (Nederlands).

Only the taxonomy of "Years" I have created the translations for, but also for this car it's not showing the translated content on the listing page of that vehicle. It keeps showing "Year" instead of "Jaar".

Thought this would work right away because it had worked in the past on my live version and thought it only went broken after setting the default language to Dutch afterwards. For now I've left the default language set to English so I would expect it to work.

June 11, 2024 at 7:19 am #15724788

Paola Mendiburu
Supporter

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

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

Please let me know how I can reproduce the issue.

June 11, 2024 at 8:48 am #15725285

stephanosP

Hi,

You can go to the "Inventory" tab and then open the first listing "Tesla Roadster" for example. On the right you'll see "Year" which is the default English word for it. If you then switch to the Dutch (Nederlands) version of that page, it should translate "Year" to "Jaar" but it keeps it displayed as "Year".

In the strings, taxonomy etc everything for "Year" have been translated.

June 12, 2024 at 9:40 am #15730489

stephanosP

Any update in regards to this?

June 12, 2024 at 10:01 am #15730730

Paola Mendiburu
Supporter

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

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

Ok thanks.

I am investigating,

It seems a problem in the template for the cars, do you what is the file for that template of the theme?

June 12, 2024 at 11:31 am #15731220

stephanosP

Not really I'm sorry. Would need to be checked manually I'm afraid.

June 13, 2024 at 7:22 pm #15737694

stephanosP

Did you manage to find anything?

June 14, 2024 at 5:04 pm #15740958

Paola Mendiburu
Supporter

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

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

Finally I have found a solution, as you can see here Year appear translate:
hidden link

- please go to wp-content\plugins\stm-motors-extends\inc\widgets\classified-four-car-data.php file
- Replace the line 129:

<?php echo esc_html( apply_filters( 'stm_dynamic_string_translation', $data_value['single_name'], 'Listing Category ' . $data_value['single_name'] ) ); ?>

- with the following code:

<?php // WPML Workaround for compsupp-6543

	//Register string
	$wpml_default_lang = apply_filters('wpml_default_language', NULL );
	$wpml_current_lang = apply_filters( 'wpml_current_language', NULL );

	if ($wpml_default_lang == $wpml_current_lang ) {
		// If it's default language, register the string
		do_action( 'wpml_register_single_string', 'motors', 'label - '.$data_value['single_name'], $data_value['single_name'] );
	}											
	
	// Translate String
	$data_value['single_name'] = apply_filters('wpml_translate_single_string', $data_value['single_name'] , 'motors', 'label - '.$data_value['single_name'] ); 

?>
<?php echo esc_html( $data_value['single_name'] ); ?>

Please let me know if you need help applying the solution. For that I will need FTP access or permission to install plugin File Manager.

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