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.

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by Elisabeth 1 year, 8 months ago.

Assisted by: Mohamed Sayed.

Author Posts
September 19, 2023 at 3:34 pm #14421047

Elisabeth

<?php esc_html_e( 'Learn More', 'emeline-core' ); ?>

the "Learn More" should be a different text in German.

I used to use this code:
<?php _e ('English'?>
<?php _de ('German'?>

But somehow I cannot use this type of syntax with the above code. Could you please give me an example or advice?

Thanks!

September 19, 2023 at 10:32 pm #14425611

Mohamed Sayed

Hi there,
Thanks for contacting WPML support.

I see that the original text is wrapped in gettext calls and has a textdomain argument, so it's supposed to be translatable.

Please try the following steps:

- Go to WPML > Theme and plugins localization
- Select the theme/plugin where the string is coming from
- Scan it for strings
- Go to WPML > String Translation
- Search for the string and translate it

Let me know please if that helps.

Kind regards,
Mohamed

September 20, 2023 at 10:03 am #14428627

Elisabeth

Hello Mohamed and thanks for getting back to me. The text is in the parent theme, but I could not find it there after scanning the strings in the theme. Is there any way I can simply add code to the php file?

I used to use this code:
<?php _e ('English'?>
<?php _de ('German'?>

but that breaks my site...?
Thanks!

Bildschirmfoto 2023-09-20 um 12.02.35.png
September 20, 2023 at 6:39 pm #14432981

Mohamed Sayed

Hi,

Please note that debugging the custom code is out of the scope of our support, but I will try to point you in the right direction.

In order to output different code based on the language, using the "wpml_current_language" hook might help. Please check the following links for more details:

- https://wpml.org/wpml-hook/wpml_current_language/
- hidden link

So you can try something like the following:

$my_current_lang = apply_filters( 'wpml_current_language', NULL );

if($my_current_lang=='en'){
 // Add the code outputs the English text
	} else {
  // Add the code outputs the German text
}

I would also suggest trying the following steps to translate the text with String Translation:

- Go to WPML String Translation
- Scroll down to the "Auto register strings for translation" section and enable that option
- Visit the page where the string is added on the front end
- Go back to String translation and disable the auto register option
- Search again for the string and translate it

Kind regards,
Mohamed

Screenshot_173.png
September 21, 2023 at 6:04 am #14434597

Elisabeth

Hi Mohamed, I solved it by using the auto register strings for translation, thank you again for your support and have a great day 🙂

September 21, 2023 at 6:04 am #14434601

Elisabeth

Great support, merci!