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.

No supporters are available to work today on this forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

This topic contains 3 replies, has 3 voices.

Last updated by pavlinaD 1 year, 7 months ago.

Assisted by: Andreas.

Author Posts
March 23, 2023 at 11:39 am #13314675

pavlinaD

Hi there,

Hope you're doing well!

Tell us what you are trying to do?
- we have coded a slider which has 2 buttons with hardcoded strings for the button text, we want to make these texts translatable.
The php file is found within: .../wp-content/themes/astra-child/assets/shortcodes/homeslider.php - "shortcodes" folder is created by us, doesn't come with the child theme, the rest is the default structure.

These are the strings in question: hidden link - here is where they appear on the front-end: hidden link. We tried changing the code to: hidden link and this is what this resulted in on the front-end: hidden link. Still went through scanning the child theme for new strings, but nothing changed.

We checked that "themedomain" matches our child theme domain as instructed in your tutorial: hidden link.

Is there any documentation that you are following?
- we tried this: https://wpml.org/forums/topic/translate-function-php/

What is the link to your site?
- hidden link (private staging, we can provide access)

Could you please direct us how to change the code perhaps so that it works in our case? 🙂

Thanks in advance!

March 23, 2023 at 12:12 pm #13314981

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

thanks for contacting us.

All looks good, except for one thing. You are adding PHP code inside HTML as I can see, in that case, you need to wrap that code inside PHP tags.

For example:

<h2><?php _e( 'Thank you!', 'my-plugin-domain' ); ?></h2>

I suggest checking the next documentation from our side which few more examples of how to use it properly.

- https://wpml.org/documentation/support/enabling-text-translation-for-themes-not-compatible-with-wpml/

After that, just regularly scan theme files nad you should be able to translate it via WPML String Translation.

Let us know how it goes.

Kind regards,
Drazen

March 23, 2023 at 1:01 pm #13315397

Andreas

Hello there

Thank you for contacting us. I am happy to help you.

First of all custom code is our of the scope of this support , however I will help you with a few tips.

When you make changes in code and you need then to rescan the files, in your case Astra theme, you need to rescan the files in order to String Translation read the new changes:

https://wpml.org/documentation/getting-started-guide/string-translation/finding-strings-that-dont-appear-on-the-string-translation-page/

Now based on your code, I can see that they are some errors using the gettext function and this is the reason you can see the wrong data in the frontend.

The alias of gettext php function is _() , so since you see that _() in frontend you are using the wrongly gettext function.

Please read our developers documentation for more details and examples

https://wpml.org/documentation/support/enabling-text-translation-for-themes-not-compatible-with-wpml/

I hope this helps. Please let us know how it goes or if you need any further assistance. I'll gladly help you. 🙂

Regards,
Andreas

March 23, 2023 at 3:33 pm #13316799

pavlinaD

We managed to resolve the issue using the snippet, provided by Drazen. Thanks heaps, guys!