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 5 replies, has 2 voices.

Last updated by Andrey 1 year, 2 months ago.

Assisted by: Andrey.

Author Posts
October 17, 2023 at 12:29 pm #14594145

Swen Kleibrink

Tell us what you are trying to do? I added the code e(....) to the code snippet so string translation can find it.

This is the code

add_action( 'woocommerce_after_add_to_cart_button', 'my_function_sample', 10 );
function my_function_sample() {
global $product;

echo "<button type='button' onclick=\"location.href='hidden link'\" class='single_add_to_cart_button button alt wdm_enquiry' style='background:rgb(0, 171, 0) none repeat scroll 0% 0%';>Back to Shop</button>";

}
I found the text string and created an English version that says "Back to Shop" the the link to follow the en/shop-products page...

Is there any documentation that you are following? yes yours

Is there a similar example that we can see?
Yes - for example a product in German and English hidden link displays Zum Shop next to the add to cart button but the English page
hidden link still says "Zum Shop"

What is the link to your site? see above links

a173d3c8-9ef7-481c-95f2-96f2f8debd22.png
October 17, 2023 at 8:12 pm #14597761

Andrey
Supporter

Languages: English (English ) Russian (Русский )

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

Thank you for contacting WPML support.

To translate the strings in the code snippet, you have to localize them. The text must be wrapped in gettext calls.

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

October 17, 2023 at 8:14 pm #14597763

Swen Kleibrink

I see you did not read my support what a waste of time !!!!!!
I already did what you said if you would read my message please dont waste my time I dont have it!

October 17, 2023 at 8:23 pm #14597795

Andrey
Supporter

Languages: English (English ) Russian (Русский )

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

I have read it carefully. As I mentioned before, you did not localize the string in the snippet you shared. Please share an updated snippet with me if you did as you said.

I suggest the following:

– Localize the string in the snippet
– Added it as a test to the functions.php of your theme
– Scan theme in WPML → Theme and plugins localization
– Translate only text from the snippet in WPML → String Translation

October 20, 2023 at 7:08 am #14620705

Swen Kleibrink

according to you article it is supposed to be formated like this
add_action( 'woocommerce_single_product_summary', 'my_function_sample', 10 );
function my_function_sample() {
global $product;
_e( "<button type='button' onclick=\"location.href='hidden link'\" class='single_add_to_cart_button button alt wdm_enquiry' style='background:rgb(0, 171, 0) none repeat scroll 0% 0%';>Zum Shop</button>");
}

and it is found in string translation and translated but on front end not

October 20, 2023 at 7:21 am #14620755

Andrey
Supporter

Languages: English (English ) Russian (Русский )

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

Thank you for the update. Please try to remove the current string from WPML → String Translation, register and translate it again.

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

Have you tried to add your snippet to the functions.php of your current theme?

To help you faster, I've enabled debug information for this support ticket. Please see this link for how to get this information from your site and give it to us: http://wpml.org/faq/provide-debug-information-faster-support/