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.

Our next available supporter will start replying to tickets in about 5.76 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 15:00 8:00 – 15:00 8:00 – 15:00 8:00 – 15:00 - 8:00 – 15:00
- 16:00 – 17:00 16:00 – 17:00 16:00 – 17:00 16:00 – 17:00 - 16:00 – 17:00

Supporter timezone: Europe/Rome (GMT+01:00)

This topic contains 12 replies, has 2 voices.

Last updated by Alejandro 1 year, 10 months ago.

Assigned support staff: Alejandro.

Author Posts
January 14, 2021 at 7:03 pm

emelieC

I believe I have the same issue as described in another thread.

I am trying to translate the choices in ACF. I need to set their original language as well as define what their translations are.

This is the thread, where, your colleague suggests a code. I am not sure if you have created a feature for this or if I still need the code. If the code is still needed, where do I put it, and will the "choices" then be available in string translator? https://wpml.org/forums/topic/how-to-only-translate-the-acf-choices/

January 14, 2021 at 8:10 pm
January 14, 2021 at 8:17 pm #7848291

emelieC

I have received the chat transcript. Please update as soon as possible on this.

It would in my opinion be a much better idea if each row would become its own string in string translator. That would fit better with how the rest or WPML works.

Looking forward to specifically two things:

Is it really like I have been described? Can I just translate each row of the "choices"?

How would I set the current language or the default language of the choices? Also considering some fields might be in English and some Spanish, how would that work? Or is the language solely defined by the page language, so all choices have to be the same default language?

Would I in my case need to change the import language to Spanish?

Also, how would my system be affected by this change? For instance I am using the fields to bring data to my tables that are seen when making a tyre search on the home page. Please have a go at that to see how things currently work on my site.

Thanks!

January 16, 2021 at 12:29 pm #7858711

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

Hello there!

I saw the code that you currently have but i couldn't really spot the place that was giving you trouble (i.e the choices coming from ACF).

In order to easily auto-register a string coming from a dynamic source you can use this filter:
https://wpml.org/wpml-hook/wpml_register_single_string/

Then, to retrieve the translation you can use this one:
https://wpml.org/wpml-hook/wpml_translate_single_string/

You can check this code example from another ticket: https://wpml.org/forums/topic/translation-acf-field-on-options-page-after-wpml-update/#post-7335367

As you can see, by using the hooks mentioned above i am able to get the content from ACF, register it automatically in WPML > String Translation.

Then i can translate it in String Translation and it will always show the translation in a more dynamic way without hardcoding text anywhere.

Could this be a suitable solution or you?

January 16, 2021 at 3:00 pm #7859275

emelieC

I was chatting with someone if you take a look above .

I was expecting that same person to double check. Have you read the chat? Can the original supporter get back to me? If not and if you will help me, I would need more detailed and hands on answers and I would need you do read though the chat thoroughly so we are on the same page.

Thanks a lot

January 16, 2021 at 4:07 pm #7859507

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

Hello!

Sorry for not stating it before, but yes, i have read the chat ticket before answering to your question. he's not here today since it' his weekend so he can return on monday and if you want to continue with him, then i can reassign it to him.

However here's the thing, i checked the code on the pastebin and thought the problem was that you had a field that you wanted to translate in the front-end.

I accessed the site again and this time i discovered something very basic that still hasn't been done so let's do this: Let's start by meeting WPML's minimum requirements.

Please add the following code in your wp-config.php file, right after the database information lines of code:

define('WP_MEMORY_LIMIT','256M');

Without this, nothing will probably work correctly.

then you mentioned this field group in the chat: hidden link

Well, you still haven't configured the fields there, in fact if you check the "translation preferences" on each field inside the field group, you'll see they are not translated.

At the same time, you have the field group custom post type as translated, which is something that you shouldn't do, either.

So right now the problem could very well be a configuration problem.

I have recorded myself showing you what you can do, so you can start by that, but please do so only after a backup of your site.

hidden link

After all of this is done, please update the page in the original language by adding a character to the tile + save it. then try to translate it and you'll at least send the content correctly to the translations.

I know this is not the exact answer you were probably hoping for and there might be something else to do here afterwards but this are the first and required steps in order to make ACF work with WPML correctly, as stated here: https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/

Let's start with that and then we will slowly get to what i had answered previously, ok?

Just so you know, i know that the problem that you first stated is with the "group" field, that contains the options and that was the entire focus of my last answer. everything will make sense after this, i promise 🙂 but first let me know when all i suggested above will be done.

January 28, 2021 at 8:12 pm #7956229

emelieC

Im still looking into this, please don't close 🙂

January 30, 2021 at 8:08 am #7966183

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

No problem, take your time 🙂

January 31, 2021 at 10:43 am #7970437

emelieC

Alright Alejandro! Muchisimas Gracias!

Thank you for an awesome video!

I thought I had not configured something correctly because of those red warnings, but i didn't figure out that each custom field option actually had a translation setting. Thats awesome!

Ok. So I have:
1. Backed up the site
2. Fixed the memory issue.
3. Turned off translations for the actual Field Groups
4. Set the translation setting for each option Copy for all but Group which I set to translate
5. Changed to use classic translator for Pages. (this is how we normally do it)
6. I made a duplicate for the Home page because we are going to translate the page at a later stage

7. I am now searching the string translator for the options like Turismo but cant find it still.

Where do I actually place the translation and define the language of the option? Like Turismo I need to define that that is actually in Spanish, and I need to be able to translate it to English.

I believe that your initial message would solve the above questions, but I am a bit lost here 🙂

Don't want to break something. Seems complex!

Thanks for your great support!

Marcus

February 1, 2021 at 8:14 am #7974043

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

Ok, we can jump to that now that you mention you had configured the rest.

This thread might be of use to you: https://wpml.org/forums/topic/translation-acf-field-on-options-page-after-wpml-update/#post-7335367

In order to translate the option labels coming from select fields or similar, you have to make use of 2 hooks:

https://wpml.org/wpml-hook/wpml_register_single_string/ (this will register the option in WPML > String Translation)
https://wpml.org/wpml-hook/wpml_translate_single_string/ (this one will allow you to always fetch the translation from WPML > String Translation)

The logic behind is is that:

- You get the label from ACF in your template's code
- You then register it in ST using the wpml_register_single_string hook
- You then wrap the label echo/output with the wpml_translate_single_string hook
- You check it out in the front-end so the code is executed
- You then will see the string in WPML > String Translation
- you can translate it from there
- Next time the code is executed you should see the translation coming from String Translation.

Try it out and if you still can't have it working, please let me know:

- The code snippet where the labels (choices) are being output with ACF.

That way i might be able to chck why is it not working.

Regards.

February 2, 2021 at 8:42 am #7983981

emelieC

Hello Alejandro!

I looked at the code from the conversation you posted, but it doesn't look anything like the codes in the examples. I am a designer, so these things are really beyond me :p

Is there any chance you could help me through this?

February 2, 2021 at 1:17 pm #7987649

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

Ok, so let's see. in order for me to help you i'd need to know what you already have and how you have the choices created.

What i understand that you want to do is print the choice in the front-end and then have it translated. if this is the case, can you tell me how and where you're printing this information?

February 3, 2021 at 7:49 am #7992961

emelieC

Ok, I belive I have left you access already.

I need the "Group" content / options to translate. I have set it translate.

Great tool this loom. Let me see if I can show you everything quickly:

hidden link

Thanks!

February 3, 2021 at 10:12 am #7994393

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

Hi there,

First of all thanks for the video.

- what you show in minute 4 (the front-end result) is, i theorize, added using custom code in one of your site's php files, correct?

- In that code you should have an ACF function that prints the label coming from the choices of that selct field you showed me in minute 1-3 (turismo, furgoneta, etc).

- That function there needs to be wrapped around this hook before it's printed: https://wpml.org/wpml-hook/wpml_register_single_string/

- then, you need to print it (i guess it will be inside a foreach or any other loop judging from what i see in the video) wrapping around the ACF function or variable that contains the labels, using this hook instead: https://wpml.org/wpml-hook/wpml_translate_single_string/

- then, you need to go to the front-end showed in minute 4 of the video and open the select form that contains the options so they get registered in WPML > String Translation.

- then you can translate them and you'll see them in the front-end translated correctly.

If you tell me where is the code that prints the choices (you can ask your devs about it) i can take a look at it so i can better understand what we're dealing with here.

The topic ‘[Closed] I am trying to translate the choices in ACF’ is closed to new replies.