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

Last updated by Shekhar Bhandari 3 months ago.

Assigned support staff: Shekhar Bhandari.

Author Posts
July 11, 2019 at 3:15 pm #4191457

nilsT-3

Hello Support-Team,

First of all, this is my Setup:
Wordpress in combination with ACF PRO, WPML and ACF to REST API (hidden link) for the backend. We do not use WP as a frontend. We developed our own frontend. Therefore we have to fetch all data via API.

I have two questions.

1. Question - Is there any possibility to keep the same ACF fields for all the languages within a single ACF Field Group?
Explanation:
I have several Field Groups within ACF which I want to translate. To do this, I click on the Custom Fields tab on the left side menu in WP, then click on my Field Group I want to translate. On the right side I see the WPML menu where there is a table with my languages which I defined beforehands. If I click the "+" in the "Translate" column for a specific language, I get redirected to add a new Field Group. But in my case, I want to keep my Field Group structure of my "original" language. I don't want to create the Field Group again.

For that reason I followed this tutorial (hidden link). They say, that you have to duplicate the site and later change the mode to "Translate independently". That makes no sense for me, because what happens for example when I add a field to my group in a specific language. Then it doesn't sync anymore with other languages, right?

So my question is: Is there any possibility to keep the same ACF fields for all the languages within a single ACF Field Group?

2. Question - Get page IDs from API
As I mentioned beforehands, I want to fetch all data via ACF to REST API plugin and the standard WP API. I found out, that WPML saves different posts with a unique ID in the background for every language. That is actually no big deal, but how to figure out which ID is used for the translated pages via API.
Example:
I fetch the data from a service page with id 31 via:
mywebsite.com/wp-json/wp/v2/service/31
I get a response for the "default" language.

Is there any way to find out the IDs of the translated pages via API? For Example the translated pages are ID 182 and 65. How to get these IDs?

Thanks in advance!

July 12, 2019 at 3:55 am #4194897

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Welcome to WPML support. I'd be assisting you further on this issue.


Is there any possibility to keep the same ACF fields for all the languages within a single ACF Field Group?

The current way is to duplicate the field groups and change the mode to "Translate Independently" later on. and as you mentioned yes, it doesn't synchronize so you have to manually make changes in the secondary languages field groups.

But here is one thing, if you are using WPML translation editors then it's not required to translate the field groups at all.

Field groups only represent the backend interface so you can continue using it without translating it when using with translation editors, just set the fields as translate, copy, accordingly and use it in any languages.

https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/#translating-acf-user-interface

2. Question - Get page IDs from API

Can you check the solution provided here and let me know if this helps:
+ https://wpml.org/forums/topic/rest-api-posts/
+ https://wpml.org/forums/topic/how-to-get-translated-post-via-origin-post-id-through-rest/

Look forward to your reply.

Thanks

July 12, 2019 at 11:20 am #4198033

nilsT-3

First of all, thank you very much for your fast support. I still have some questions to both topics.

To the first question:
I tried that out, but I think I had the wrong wording for my question. I don't want to translate the Field Group name itself. I want to translate all the fields in a specific Field Group.
Here is an example:
I have the Field Group "Contact UI" with 12 different Fields. Every Field should be translated.
When I do what you mentioned, I can only edit the Field Groups name.

To the second question:
The first solution does not work for me. When I fetch for another language like examplepage.com/de/wp-json/wp/v2/service/31 I also get the english content.
I also tried examplepage.com/wp-json/wp/v2/service/31?lang=de
The second solution does not indicate the information about the translated pages. I don't have the array "wpml_translations" in my response. I don't get any information through API about other languages.

The requests I tried:
examplepage.com/wp-json/wp/v2/service/31
examplepage.com/de/wp-json/wp/v2/service/31
examplepage.com/wp-json/wp/v2/service/31?lang=de
In every case I don't get information about the language. Also for the ACF to REST API endpoints like:
examplepage.com/wp-json/acf/v3/options/locations
I don't get any language indication.

July 15, 2019 at 3:47 am #4206815

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

I hope when you mentioned "Every Field should be translated." you are mentioning field values if so you can set the fields to copy, translate accordingly and translate it.

Thank you for the details, can you once try if it works properly with the posts? Also, the /de/ or ?lang=de will differ according to the the URL format you are using so I request you to adjust it properly.

Look forward to your reply.

Thanks

July 15, 2019 at 6:54 am #4207555

nilsT-3

Hi,

I just list you how I tried to translate and how it failed. I try to translate an ACF options page.
1. While on the Options Page pane I created beforehands: Switch the language at the top menu. - Error: "No Custom Field Groups found for this options page. Create a Custom Field Group"
2. While I'm on the Custom Fields pane to edit a Field Group and click on "Translate" in the left side language menu. - Error: It does not apply the already created fields nor copies it to the secondary language. There is an empty Field Group.
3. Custom Fields pane: Edit a Field Group and click on "Duplicate" in the left side language menu. - Error: It copies the already created fields, but I have no option to "Translate Independently".
4. Translate with the Advanced Translation Editor. - Error: I cannot translate the field values even they're on "Translate". I can only translate the Field Label and Field Name of that Group.

As you you mentioned it works with posts. How do I configure that it works with an ACF options page?

Thanks

July 15, 2019 at 8:49 am #4208441

nilsT-3

Hi,

as I found this post (https://wpml.org/forums/topic/acf-options-page-being-translated/) from 2017/2018 it was not possible to make proper translation of an options page. Is it resolved in meanwhile? Do you have a workaround?

Thanks

July 15, 2019 at 9:08 am #4208773

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

It's possible to translate the options page, you should translate the options pages values using the top bar switcher?

So it seems you were trying to translate the acf fields groups, so can you follow this and let me know if this helps? https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/#translating-acf-user-interface

Also, if the problem exists, I would request you to provide me a few screenshots so I can help you further.

Look forward to your reply.

Thanks

July 15, 2019 at 1:44 pm #4211617

nilsT-3

Hi,

English is set as default language.
1) I have an ACF options page with several ACF options sub pages [1.png]
2) In [2.png] you see the general view of an ACF options sub page. This specific one is called "Services".
The aim is to translate these field values. For example I want to translate the value of "Name" and "Description" - not "Name" and "Description" itself.
3) If I switch the language at the top to "German" I get what is shown in [3.png]. But I don't want to configure a new Custom Field Group. I want to keep the existing one and just translate it.
4) If I go to the Custom Fields Menu at the left side and click on my ACF Field Group "Services", I have an option to "Translate" or "Duplicate" the Field Group [4.png].
5) If I click on "Translate" I see what is shown in [5.png]. But this is not everything I want to edit. There are a lot more Fields I want to translate.
6) If I click on "Duplicate" instead, I see what [6.png] shows. This is almost what I want: I copied the Field Group. The only problem there is when I change a value, it's also changed in any other language which I don't want. And as you can see, I don't have the option to "Translate Independently.

How to translate the Field Group values?

Thanks

July 16, 2019 at 4:20 am #4216007

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Duplicating the fields should help if you have created the theme options page correctly? Can you please provide me a few examples of how you have created the theme options page and the subpages?

Look forward to your reply.

Thanks

July 16, 2019 at 6:08 am #4216505

nilsT-3

Hi,

But as I said before "[...] when I change a value, it's also changed in any other language which I don't want.". I don't want to duplicate and synchronize all of the values. That makes no sense when you want to translate a page.

To create an options page you can edit functions.php in your theme settings (e.g. .../wp-content/themes/twentynineteen/functions.php):

if( function_exists('acf_add_options_page') ) {
    acf_add_options_page();
}

To add options subpages you can add:

if( function_exists('acf_add_options_page') ) {
    acf_add_options_page(array(
        'page_title' => 'Theme General Settings',
        'menu_title' => 'Theme Settings',
        'menu_slug' => 'theme-general-settings',
        'capability'	=> 'edit_posts',
        'redirect' => false
    ));
	
    acf_add_options_sub_page(array(
        'page_title' => 'Theme Header Settings',
        'menu_title' => 'Header',
        'parent_slug' => 'theme-general-settings',
    ));
	
    acf_add_options_sub_page(array(
        'page_title' 	=> 'Theme Footer Settings',
        'menu_title'	=> 'Footer',
        'parent_slug'	=> 'theme-general-settings',
    ));
}

Thanks

July 16, 2019 at 10:56 am #4219443

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

To further debug this issue, I would need to check your site settings once, for this I would need temporary access (wp-admin and ftp) to your site.

So could you please provide me those details, you will find the needed fields for this below the comment area when you log in to leave your next reply.
hidden link

This info is private and available to you and WPML supporters only.
Read more about this: https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

Note:
Backup your sites before providing the credentials or if possible provide credentials for the test site

Look forward to your reply.

Thanks

July 18, 2019 at 12:10 pm #4238531

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

The site looks totally different, can you please share me a link where the acf fields are being used?

Look forward to your reply.

Thanks

July 18, 2019 at 12:16 pm #4238607

nilsT-3

Hi,

on the left side there is a submenu with a "+" as image. It's right under the Dashboard.

Thanks

July 19, 2019 at 3:19 am #4243573

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

#1
- I went to hidden link and duplicated the custom fields group to Turkish and it went well.

- I also tried to duplicate it in German, but couldn't. I noticed that you have 4 services fields already in german so I request you to delete them once and try to duplicate it, this should work properly.

- After this, I went to hidden link and when I switch to Turkish I can see the fields, so the custom fields duplication is working.

#2
I further went to theme functions.php to find the theme options code that you are working and I noticed the code is slightly different than what you posted here before

acf_add_options_sub_page(array(
            'page_title' 	=> 'fable+ General Settings',
            'menu_title'	=> 'General',
            'parent_slug'	=> 'fable-content',
            'menu_slug' 	=> 'fable-general-configuration',
            'update_button'	=> __('Save', 'acf'),
            'updated_message'=>__("General settings saved", 'acf'),
            'post_id'       => 'general'
        ));

You are using post_id here with a 'general' slug. A post_id with slug options is auto-translated with WPML but other slugs don't get translated, so to fix the issue you can use the suggestion provided here: https://wpml.org/forums/topic/acf-options-page-field-values-not-able-to-translate/#post-3804405

Let me know if this helps.

Thanks