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 6 replies, has 3 voices.

Last updated by jasonE-3 1 year ago.

Assigned support staff: Diego Pereira.

Author Posts
September 14, 2018 at 8:05 am #2734460

desireeD-2

Hi,

I have translated a page which makes use of the ACF flexible content field. Basically, everything works, but I have two issues which could work better.

1. The flexible content field contains the ACF field type "Link", which contains a Link/URL to another static page on my website (e.g. "Contact english"). When I translate the page to the secondary language, I would like the link field to point to the static page in the secondary language (e.g. "Contact german"). However, in the translated page the link field still points to the page in the primary language. Of course, I could insert the link to the secondary language page manually, but that's error-prone and means more steps for my editors.
See screenshots 01_1 and 01_2.

2. Every time an editor adds a new flexible content field group to the existing page (with existing translation), I have to configure the "Multilingual Content Setup" seciotn of this page and set the desired options for the new sub fields (e.g. copy/translate). Whats even more cumbersome, I have to display the system fields and set each system field to "copy" manually (otherwise the translated fields do not show up in the frontend). So, is there a way to define/preset the translation options for subfields of a field group? E.g., always translate text field Foo, always copy image foo, etc.. See screenshot 02_1.

Thanks!

September 16, 2018 at 4:26 pm #2739073

Diego Pereira
Supporter

Languages: English (English ) Spanish (Español ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello @desireed-2, welcome to the WPML support Forum!

Here is our guide on how to use WPML + ACF: https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/

Usually WPML scans the content of the post and adapts the links automatically. Please try setting the Link field to "Do not Translate" or "Copy" and check if the link is modified in the translation. Please remember to do small modification on the page content (original language) + saving before testing.

If it does not work, please test with the Sticky Links extension: https://wpml.org/documentation/getting-started-guide/sticky-links/

You can download from here: https://wpml.org/account/downloads/

All the best,
Diego

September 16, 2018 at 4:39 pm #2739079

Diego Pereira
Supporter

Languages: English (English ) Spanish (Español ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

For the issue number 2, each repeater field is registered as a new field, so it is necessary to set the translation options again.There is a meta box in bottom of post edit screen. Once you create a new row or new fields in post you can update the post and choose the action from there.

The best workflow to translate ACF Fields with WPML is to duplicate the post then translate independently. This way the fields will be automatically copied to the translation.

If you need more help just let me know.

Regards,
Diego

September 18, 2018 at 10:23 am #2744480

desireeD-2

Hi Diego,

on your reply #2739073: I tried setting the link fields to "copy" and "do not translate" and making small modifications in teh original language, as you said. However, in the translation, the links are unchanged and still point to the primary language. So the only solution seems to be to translate the links manually.

I do not see how Sticky Links could help, as I do not have any broken links. The best possible solution for me would be if WPML scanned the content of the post/the ACF fields and adapted the links automatically, as you said would be the normal case. Is there any setting which could prevent this behavior?

September 18, 2018 at 8:50 pm #2746499

Diego Pereira
Supporter

Languages: English (English ) Spanish (Español ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi there,

Sorry, I checked with my team and this automatic link translation only works with links within the main WYSIWYG of the post and some page builder fields. Unfortunately it does not work with ACF at the moment.

There is a similar ticket available here: https://wpml.org/forums/topic/link-targets-in-acf-wysiwyg-field-not-being-automatically-translated/

It's also possible to write your own script to update the URLs. For this you can use the wpml_element_link filter (https://wpml.org/wpml-hook/wpml_element_link/)

This approach, however, is beyond the scope of our support forum. If you need, we have a list of experienced contractors available here: https://wpml.org/contractors/

Here is our complete list of hooks/filters: https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/

If you need more help just let me know.

Kind regards,
Diego

September 19, 2018 at 5:44 am #2747289

desireeD-2

Ok, thanks, that's valuable information, so now I can stop trying. The script could be worth a try, although I tend to let the editors translate the links manually.

July 8, 2019 at 4:26 pm #4164333

jasonE-3

If you take the URL from the link field and pass it into url_to_postid() - then take that ID and pass it into get_the_permalink() - you will get the translated URL.

$link = get_field('link');
$link_post_id = url_to_postid($link['url']); // This returns 0 if not found, so you can detect an external link
$translated_url = get_the_permalink($link_post_id);