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.

Tagged: 

This topic contains 20 replies, has 2 voices.

Last updated by lindaL-3 1 year, 6 months ago.

Assisted by: Nigel.

Author Posts
September 25, 2022 at 7:38 pm #12119535

lindaL-3

Hi,

I'm building a site for a car dealer and have created a custom post type 'cars' with 17 meta fields. Most fields are numeric so can be copied from the source rather than translated. Everything works fine.

However, I'm struggeling with one field: stock status. This can be:
- For Sale, Sold, Expected, Reserved

What I'm trying to achieve: I would like to translate these values once and then have them synchronized across all languages. So, when a car for example has the status 'Expected' and needs to go to 'For Sale' as soon as the car comes in, I would like it to be one action in the source language of the website.

I can simply translate the custom post type and translate the status. But there will be 4 languages in the end so that would mean with every status change 4 translations have to be updated. I'm sure this can be done much smarter, I only haven't been able to figure out how.

Hope you can help. Many thanks in advance.

Best regards,

Nick

September 27, 2022 at 12:27 pm #12131465

Nigel
Supporter

Timezone: Europe/Madrid (GMT+02:00)

Hi Nick

What are you using for the custom fields? I see you have ACF installed.

This field in question, it's a select dropdown or similar type of field?

It sounds like you want the stored values of the field to be the same across languages (e.g. "expected", or it could be a number, e.g. 1 = "expected", 2 = "for-sale" etc.), and you simply want to translate the labels.

So set the custom field to Copy (changes made to the field in the default language will be reproduced in the secondary languages), but translate the labels.

If you are using ACF, check this link about what's required for translating labels of select fields etc.: https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/translating-acf-field-labels-and-labels-for-choices-with-wpml/

September 28, 2022 at 8:13 pm #12144311

lindaL-3

Hi Nigel,

Thanks for your reply.

ACF is installed but I'm not using it (came with the theme).

I created the custom post type in JetEngine and the custom field is of type 'select' (see attached screenshot meta-field-voorraadstatus.jpg). The actual values of the fields come from a glossary in JetEngine (see attached screenshot glossary.jpg).

So, I can find the custom field in WPML > Settings > Translate custom fields and I've set it to copy. Then I can go to String Translation to translate the labels. But, for some reason these fields are being marked as 'English' (see attached screenshot string-translation-label.jpg). I tried creating the labels in English and then add the Dutch and German translation but this didn't work. Also, when I created a translation of the label, this translation popped up as a new line in String translation...see screenshot string-translation-2.jpg for clarification.

I'm a bit lost here honestly...I think I should somehow mark these labels as 'Dutch' in String translation as this is the main language of the site but I don't know how. Or maybe these strings are not even the correct ones as these are part of domain ' Jet Engine Admin Labels'.

One side question if I may: is there a possibility in WPML > Settings > Translate custom fields to get rid of the fields that are no longer existing? Somehow all old fields remain in the table...

Thank you in advance. Best regards.

string-translation-2.JPG
string-translation-label.JPG
glossary.JPG
meta-field-voorraadstatus.JPG
September 29, 2022 at 7:35 am #12146511

Nigel
Supporter

Timezone: Europe/Madrid (GMT+02:00)

Hi Nick

OK, so it sounds like your problem is the default characterisation of the strings as English, when they should be Dutch.

Please check this documentation for how to handle that: https://wpml.org/documentation/getting-started-guide/string-translation/how-to-change-the-source-language-of-strings/

As for your side question, about how to "get rid of the fields that are no longer existing", that's not something WPML can help with.

You see those custom fields in the WPML settings, because WPML detects those custom fields (the meta_key's) in the wp_postmeta table.

At some point you have created posts with values for such fields, and have later removed the settings for the custom fields, but the data itself is still stored in wp_postmeta.

If the posts to which those custom fields belonged no longer exist, you could use a database clean-up plugin, which could identify orphan entries in wp_postmeta (custom fields that didn't belong to an existing post) and remove them.

But if the posts still exist, and it's just that you no longer need the custom field entries, that would require a more manual intervention. You would basically need to make a list of all of the custom fields you wanted to remove from your site, and then either write a PHP script to delete them, or a SQL query that you could apply directly, using something like phpMyAdmin.

September 29, 2022 at 12:09 pm #12148963

lindaL-3

Hi Nigel,

Thanks again for the quick reply.

I was able to change the default characterisation of the strings to Dutch. Unfortunately, I'm still having the same issue. I think only the backend labels (see screenshot) are translated. That's probably the reason why the name of the domain is 'Jet Engine Admin Labels'.

I have 2 custom field configurations right now in my custom post:
- the meta field of type 'select' attached to the custom post type
- a seperately created Meta Box within JetEngine, which is assigned to the custom post type.

In both configurations I've added a new label and unfortunately these aren't translated in the frontend, only the labels are translated in the backend (when editing the custom post type as can be seen in the screenshot).

Does this mean the frontend labels cannot be translated?

Next to that I have a taxonomy (not preferred, for translation testing only), this seems to be translated fine.

Examples:
- Dutch: hidden link
- English: hidden link

I also don't understand why the content/design of the 'single car template' is not synchronized...I would expect to only have to translate the texts. For example the divider under the car title was added in the Dutch (source) template but is not shown in the English language.

Best regards

backend-labels.JPG
September 29, 2022 at 12:40 pm #12149275

Nigel
Supporter

Timezone: Europe/Madrid (GMT+02:00)

I haven't used Jet for creating custom fields, so I'm not sure about the best way to identify the label strings for translation, I'd need to try it and see.

If I create a sandbox site that you have admin access to, would you be able to add the relevant Jet plugin and set up a simple demo with the select custom fields registered for some post type that have the labels which need translating?

Otherwise you could provide a staging version of your site that you were happy for me to run tests on.

Let me know if either of these suits, and I'll provide what's needed.

September 29, 2022 at 12:47 pm #12149309

lindaL-3

Hi Nigel, I've edited my reply above in the meanwhile.

I will duplicate the website so you can play freely 😉

September 29, 2022 at 1:14 pm #12149767

lindaL-3

What email can I use to invite for the staging environment?

September 29, 2022 at 2:33 pm #12150595

Nigel
Supporter

Timezone: Europe/Madrid (GMT+02:00)

Let me set a private reply so you can share the credentials for an administrator securely.

September 30, 2022 at 2:45 pm #12157759

Nigel
Supporter

Timezone: Europe/Madrid (GMT+02:00)

Hi Nick

Thanks for that.

I've had a nosey around to see how JetEngine works here.

I see the custom field Voorraadstatus is registered along with the autos post type, that it is a select field where the options come from a Glossary (of the same name).

When I search in String Translation I find the texts from the glossary available for transation, and they seem to be correctly recognised as Dutch, with available translations (e.g. screenshot).

In WPML > Settings > Custom field translation the custom field ("status") is set to Copy.

So far so good, it seems.

I expect that you would make a change to a post in the default (Dutch) language, updating the value of the custom field, and on the other language versions of the post the field value should be updated to match (thanks to the Copy setting).

(The one thing I would change in your setup is to change the field values for the glossary items to be something not language-specific. Currently the values are the same as the labels. Even when you translate the labels, each language version of the post would share the same custom field value, e.g. "Te koop". You might want something like numbers, where Te koop = 1, Gereserveerd = 2, or letter codes, or similar.)

So, now that I've understood the set up, can you provide me with some steps to actually see the problem you have?

Screenshot 2022-09-30 at 15.34.13.png
October 3, 2022 at 11:32 am #12169821

lindaL-3

Hi Nigel,

Thanks for the analysis, I think you got it.

I'm not really sure if I understand your suggestion correctly. Can you please do this in the test enviroment so I can have a look?

The actual problem can be reproduced by:
1. Go to any car, e.g. hidden link
2. Go to 'Auto wijzigen' (edit button in WordPress top menu bar) to go to the backend and then change the 'Voorraadstatus' (see screenshot 1)
2. Check the Dutch single car page to verify the status got updated above 'meta field' (see screenshot 2)
3. Check the English translation of this single car page to verify that also that status got updated.

Best regards,

Nick

2.jpg
1.jpg
October 3, 2022 at 1:27 pm #12170887

Nigel
Supporter

Timezone: Europe/Madrid (GMT+02:00)

I tried that and switching the page to English it showed the field value as "TestjeMetaboxVeld", which was unexpected.

Looking again, it seems Jet has two ways of adding custom fields to custom post types, and it looks like you are using both, and I don't know which is intended, if you can please review how you have this set up and clarify.

In the settings for the autos post type (at JetEngine > Post types) you have a status field (label "Voorraadstatus") which is a select field whose values come from the Voorraadstatus glossary.

But at JetEngine > Meta Boxes you also have a Voorraadstatus metabox set up with a Voorraadstatus auto field whose values are manually added, rather than coming from the Voorraadstatus glossary.

So there seems to be quite a lot of overlap here and I'm not sure which field we are supposed to be working with. I expect it should be one or the other rather than both, but you will know JetEngine better than me, if you could please clarify.

October 3, 2022 at 5:56 pm #12172557

lindaL-3

Hi Nigel,

That's 100% accurate, I did this to test both ways and see if at least one of those would work with WPML. But unfortunately, it didn't. At least not yet.

As I wrote in my reply above https://wpml.org/forums/topic/jetengine-custom-post-type-meta-fields/#post-12148963:
I have 2 custom field configurations right now in my custom post:
- the meta field of type 'select' attached to the custom post type
- a seperately created Meta Box within JetEngine, which is assigned to the custom post type.

The preferred way is the select field whose values come from the Voorraadstatus glossary. But I haven't been able to translate the glossary values since only the 'Jet Engine Admin Labels' seem to be reaching String Translation rather than the labels that are displayed in the frontend.

And just to clarify, the end goal here is: when the status is updated in Dutch, it should automatically synchronize this status in all other languages (in its own language).

Thanks for the support, hopefully we can find a solution 🙂

October 4, 2022 at 8:54 am #12175733

Nigel
Supporter

Timezone: Europe/Madrid (GMT+02:00)

This duplication together with re-using the same texts for field values and labels makes it difficult to see what strings are being translated on your site.

So I went ahead and set up a sandbox site with a simple demo to check and illustrate how to translate such strings.

You can access it here: hidden link

I used JetEngine to register a glossary ("Stages") that includes 5 options, e.g. "First" (value = 1), "Second" (value = 2) etc.

I then registered a custom post type ("Things") and added a meta field thing-stage to it, whose options come from the glossary.

In WPML > Settings I set the thing post type as translatable, and I set the thing-stage custom field to Copy.

I created a few sample Thing posts, with values chosen for the stage field, and then translated the posts.

I verified that the translated posts have the value of the thing-stage field copied across. (I enabled the default WordPress custom field UI so that it is easy to see when editing a post the stored value for the field; if I edit the EN version of the post and then use the language switcher to change to NL or ES I can see field value.)

I made a change to the selected option for one of the posts (I edited "Something" and changed the option from First to Third) and then verified that the value for the translations of the post changed, which it did. That's one of your requirements fulfilled.

As for translating the labels, I was able to find the texts to translate using String Translation, with mixed results. It works, but there is a problem, which makes it confusing.

(On your site it is particularly confusing because, as I mentioned before, you use the same texts in different places, e.g. for the labels and the values, in glossaries and meta boxes, so it is hard to tell what text you are translating.)

On my sandbox, the default is EN and I have translations to NL and ES.

I translated the labels First, Second, Third, Fourth, Last to NL and ES.

First, the good news is that works. I was only able to verify in the back end (I don't know how you output the JetEngine field labels on the front end; I tried generating a jet shortcode which you can see I added to the post bodies, but it only outputs the stored value not the label). If you edit one of the translations of the posts, you will see the options in the dropdown are shown translated rather than in the original EN from the glossary.

Next, the bad news relates to what you were initially describing, I think. You will see that String Translation has identified the translated texts as new texts as if they were English.

You should be able to understand what I mean from the screenshot.

I need to create an internal ticket to escalate this to our compatibility team, but in the meantime you can hopefully understand that it is possible to get this working, but one thing you should do is update the texts you use in various places to use unique texts so that you can be clear what it is you are translating.

Screenshot 2022-10-04 at 09.38.31.png
October 4, 2022 at 10:00 am #12176147

Nigel
Supporter

Timezone: Europe/Madrid (GMT+02:00)

OK, I've prepared the internal tickets and shared all the details, so I'm escalating this, and will get back to you when I have any feedback.

In the meantime, though, I think you should be able to get this working on your site, in spite of the confusing interface.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.