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.

This topic contains 17 replies, has 2 voices.

Last updated by Long Nguyen 1 year, 6 months ago.

Assisted by: Long Nguyen.

Author Posts
September 19, 2023 at 2:11 pm #14420291

andrejO

I am trying to: translate two URL controls in custom elementor block with repeater

the config file for the block looks like:

<widget name="custom_carousel">
<fields-in-item items_of="slides">
<field type="Carousel: Title" editor_type="LINE">title</field>
<field type="Carousel: Description" editor_type="VISUAL">description</field>
<field type="Carousel: Primary Btn Text" editor_type="LINE">primary_button_text</field>
<field type="Carousel: Secondary Btn Text" editor_type="LINE">secondary_button_text</field>
<field type="Carousel: Secondary Btn Link" editor_type="LINE" key_of="secondary_button_link">url</field>
<field type="Carousel: Primary Btn Link" editor_type="LINE" key_of="primary_button_link">url</field>
</fields-in-item>
</widget>

I expected to see:
Both url fields translatable.

Instead, I got: Only the last one is translateble. In specified order is translatable only primary btn. If i change the order of last two <field> tags, then only secondary btn is translatable.

September 20, 2023 at 8:29 am #14427543

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi Andrej,

Thank you for contacting WPML support, I'd be happy to help you with this issue.

It looks like you are using a custom Elementor widget to display the carousel on the site. Please try to register the Elementor widget with PHP code for translation and see if it helps, refer to the documentation
https://wpml.org/documentation/plugins-compatibility/elementor/how-to-add-wpml-support-to-custom-elementor-widgets/
https://wpml.org/errata/elementor-social-icons-widget-links-and-attributes-translation-issues/

If it does not work, please try to implement the custom code and replicate the issue on the sandbox site. I will help you to check the issue. You can login directly to the admin area with the link below.
hidden link

Look forward to your reply.
Thanks

September 25, 2023 at 4:05 pm #14460461

andrejO

Hi, thanks for the links. It helped to load links for simple button link. However, I am still having trouble translating links in REPEATER fields. I have used this example code:

class Delistrap_Elementor_WPML_Carousel extends \WPML_Elementor_Module_With_Items {

    /**
     * @return string
     */
    public function get_items_field() {
        return 'slides';
    }

    /**
     * @return array
     */
    public function get_fields() {
        return array(
            'title',
            'description',
            'primary_button_text',
            'primary_button_link',
            'primary_button_link_url',
            'secondary_button_text',
            'secondary_button_link',
            'secondary_button_link_url',
        );
    }

    /**
     * @param string $field
     *
     * @return string
     */
    protected function get_title( $field ) {
        switch( $field ) {
            case 'title':
                return 'DS Carousel: Title';
            case 'description':
                return 'DS Carousel: Description';
            case 'primary_button_text':
                return 'DS Carousel: Primary Button Text';
            case 'primary_button_link':
                return 'DS Carousel: Primary Button Link';
            case 'primary_button_link_url':
                return 'DS Carousel: Primary Button Link URL';
            case 'secondary_button_text':
                return 'DS Carousel: Secondary Button Text';
            case 'secondary_button_link':
                return 'DS Carousel: Secondary Button Link';
            case 'secondary_button_link_url':
                return 'DS Carousel: Secondary Button Link URL';
            default:
                return '';
        }
    }

    /**
     * @param string $field
     *
     * @return string
     */
    protected function get_editor_type( $field ) {
        switch( $field ) {
            case 'description':
                return 'VISUAL';
            default:
                return 'LINE';
        }
    }

}

Only the title and description are being translated. The fields primary_button_link (URL control), primary_button_link_url (Text control) are not translatable.

Thanks

September 26, 2023 at 4:16 am #14462869

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Can you please implement your custom Elementor widget on the sandbox site? I will check the code that registers the Elementor widget and registers it for translation.

Look forward to your reply.
Thanks

October 5, 2023 at 10:27 am #14519453

andrejO

Please can you help me where I should implement or deploy sandbox site?

October 6, 2023 at 1:17 am #14523597

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

The sandbox site above is expired (7 days after the last login). Here is the new one hidden link

You can install Elementor and add the custom code that registers the custom Elementor widget, just like you do on your site.

Look forward to your reply.
Thanks

October 6, 2023 at 6:51 am #14524315

andrejO

Hello,

thanks for reply. I uploaded plugin with elementor widgets with repeater URL controls. I contains wpml xml config file and also wpml translations register via php code in plugin/elementor/wpml folder. Please check.

I created sample page with mentioned widget - Sample elementor page. Note that styles and scripts does not work. But that should has no effect on wpml translations.

Thanks for checking it.

October 6, 2023 at 8:19 am #14525319

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

I add the custom XML configuration code to WPML > Settings > Custom XML Configuration tab, and the URLs in the repeater are displayed as well in Advanced Translation Editor. Please check this screenshot hidden link

<wpml-config>
  <elementor-widgets>
    <widget name="delistrap-plugin-carousel">
      <fields-in-item items_of="slides">
        <field type="DS Carousel: Title" editor_type="LINE">title</field>
        <field type="DS Carousel: Description" editor_type="VISUAL">description</field>
        <field type="DS Carousel: Primary Btn Text" editor_type="LINE">primary_button_text</field>
        <field type="DS Carousel: Primary Btn URL" editor_type="LINK" key_of="primary_button_link">url</field>
        <field type="DS Carousel: Secondary Btn Text" editor_type="LINE">secondary_button_text</field>
      </fields-in-item>
    </widget>
  </elementor-widgets>
</wpml-config>

Look forward to your reply.
Thanks

October 6, 2023 at 8:30 am #14525407

andrejO

Hello, yes I know this is working. Problem is with the second URL field, you forgot it. When you define it the first one is not working, probably the xml value "url" is overriden also is key_of is different.

Please try to translate also the first and second URL field. In this example Primary Btn URL and Secondary Btn URL also.

Thanks for reply.

October 6, 2023 at 9:47 am #14526113

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

I've tried some steps to register both URL fields but do not see it work. I'm asking our 2nd tier support about this case and update you here when I have something to share.

Thanks.

October 10, 2023 at 1:42 am #14543267

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

I got a workaround from our 2nd tier support to fix this issue. Please add the code below to the file functions.php in the theme/child theme folder > make a small change to the page content > update the translation > translate the second URL.
Note: keep using the custom XML configuration code in your first comment.

add_filter( 'wpml_pb_elementor_register_string_name_delistrap-plugin-carousel', function( $name, $args ) {
	$widgetType = $args['element']['widgetType'];
	return $widgetType . '-' . $args['key'] . '-' . $args['field'] . '-' . $args['nodeId'] . '-' . $args['item']['_id'];
}, 10, 2 );

Look forward to your reply.
Thanks

October 11, 2023 at 8:34 am #14556763

andrejO

Hello, thanks for reply. I tried to solve it on demo site you provided, but its not woking. I updated plugin wpml-config.xml file and add filter in main plugin file.

Please, can you check it and try to solve on demo site?

Thanks.

October 11, 2023 at 9:32 am #14557689

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

On this sandbox site hidden link

The custom XML configuration code is added to WPML > Settings > Custom XML Configuration. And the custom PHP code is added to the file functions.php in the 2021 theme folder.

You can see both URLs are available in ATE when searching with the keyword "http", please check two screenshots
hidden link
hidden link

Refer documentation https://wpml.org/faq/how-to-translate-urls-shortcodes-and-html-attributes-using-the-advanced-translation-editor/

Look forward to your reply.
Thanks

October 11, 2023 at 4:18 pm #14560865

andrejO

Sorry, I was confused by labels of translations. There are all equal Secondary Btn URL. Can you help me how to fix labels to show Primary Btn URL and Secondary Btn URL.

Thanks for reply.

October 12, 2023 at 1:44 am #14562171

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

I'm asking our 2nd tier support about the same label in the ATE. I will update you here when I have something to share.

Thanks.