This thread is resolved. Here is a description of the problem and solution.
Problem:
You are unable to translate the words 'ingredients' and 'advice' on your product page.
Solution:
If you're experiencing this issue, we recommend you follow these steps:
1. Go to WPML -> String Translation.
2. Enable the Auto-register strings option.
3. Visit a product in the default language.
4. Return to String Translation.
5. Disable the Auto-register strings option.
6. Search for the 'Ingredients' string and translate it.
This solution might be irrelevant if it's outdated or not applicable to your case. We highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the issue persists, please open a new support ticket at WPML support forum.
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: Documentation request
This topic contains 9 replies, has 0 voices.
Last updated by irisH-8 1 week, 2 days ago.
Assisted by: Osama Mersal.
Author | Posts |
---|---|
January 27, 2025 at 2:55 pm #16638461 | |
irisH-8 |
Background of the issue: Symptoms: Questions: |
January 28, 2025 at 10:41 am #16641032 | |
Osama Mersal Supporter
Languages: English (English ) Arabic (العربية ) Timezone: Africa/Cairo (GMT+02:00) |
Hi, Thanks for contacting WPML forums support. I'll be glad to help you today. 1) Please try the following steps: 1- Go to WPML-> Theme and plugins localization, select your theme/plugin, and scan Kindly check our guide to know more about translating texts in the admin texts screen. (https://wpml.org/documentation/getting-started-guide/string-translation/finding-strings-that-dont-appear-on-the-string-translation-page/) 2) Could you please share your Debug information with me? Best regards, |
January 28, 2025 at 10:48 am #16641051 | |
irisH-8 |
Thank you for your response. The text is not from a plugin but the field is made with custom code. How can I translate this? |
January 28, 2025 at 10:51 am #16641059 | |
Osama Mersal Supporter
Languages: English (English ) Arabic (العربية ) Timezone: Africa/Cairo (GMT+02:00) |
Hi, Please make sure that you wrap the strings with the GetText function and translate them via WPML-> String Translation. Kindly check this guide. Best regards, |
January 28, 2025 at 11:02 am #16641257 | |
irisH-8 |
What do you mean with this? |
January 28, 2025 at 11:13 am #16641338 | |
Osama Mersal Supporter
Languages: English (English ) Arabic (العربية ) Timezone: Africa/Cairo (GMT+02:00) |
Hi, The gettext function in WordPress is used to translate strings dynamically. It is commonly used with the __() and _e() functions, as well as _x(), _n(), and related translation functions. Here’s a simple example demonstrating how to use gettext in a WordPress plugin or theme: return __( 'Hello, World!', 'my-text-domain' ); Please check this guide to know more info about translating custom code. (https://wpml.org/documentation/support/translating-the-theme-you-created/) Best regards, |
January 28, 2025 at 11:16 am #16641342 | |
irisH-8 |
I have this code: ///extra tabje add_filter( 'woocommerce_product_tabs', 'ingredients_tab' ); function ingredients_tab( $tabs ) { global $post; $ingredients = get_post_meta( $post->ID, '_ingredients', true ); if (!empty($ingredients) && $ingredients !== '') { $tabs['ingredients_tab'] = array( 'title' => __( 'Ingredients', 'woocommerce' ), 'priority' => 13, 'callback' => 'ingredients_tab_content' ); } return $tabs; } function ingredients_tab_content() { global $post; $current_language = apply_filters( 'wpml_current_language', NULL ); // Haal de huidige taal op $post_id = apply_filters( 'wpml_object_id', $post->ID, 'product', TRUE, $current_language ); // Haal de post-ID op voor de huidige taal $ingredients = get_post_meta( $post_id, '_ingredients', true ); $ingredients_decoded = html_entity_decode($ingredients); echo apply_filters( 'the_content', $ingredients_decoded ); } ///extra html editor bij productpagina add_action( 'add_meta_boxes', 'ingredients_meta_box' ); function ingredients_meta_box() { add_meta_box( 'ingredients_meta_box', 'Ingredients', 'ingredients_meta_box_callback', 'product', 'normal', 'high' ); } function ingredients_meta_box_callback( $post ) { $ingredients = get_post_meta( $post->ID, '_ingredients', true ); wp_editor( htmlspecialchars_decode( $ingredients ), '_ingredients', $settings = array('textarea_name'=>'_ingredients') ); } add_action( 'save_post', 'save_ingredients_data' ); function save_ingredients_data( $post_id ) { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; if ( $parent_id = wp_is_post_revision( $post_id ) ) { $post_id = $parent_id; } $ingredients = isset( $_POST['_ingredients'] ) ? $_POST['_ingredients'] : ''; update_post_meta( $post_id, '_ingredients', htmlspecialchars( $ingredients ) ); } |
January 28, 2025 at 11:21 am #16641351 | |
Osama Mersal Supporter
Languages: English (English ) Arabic (العربية ) Timezone: Africa/Cairo (GMT+02:00) |
Hi, The string seems to be added correctly: 'title' => __( 'Ingredients', 'woocommerce' ), Please check the following steps: 1- Go to WPML-> String Translation Best regards, |
January 28, 2025 at 11:25 am #16641368 | |
irisH-8 |
Which option? |
January 28, 2025 at 11:27 am #16641385 | |
Osama Mersal Supporter
Languages: English (English ) Arabic (العربية ) Timezone: Africa/Cairo (GMT+02:00) |
Hi, The "Auto-register strings" option is in your screenshot's bottom left corner. Best regards, |
January 28, 2025 at 11:32 am #16641401 | |
irisH-8 |
Thank you! |