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 thread is resolved. Here is a description of the problem and solution.

Problem:
How can I translate the strings of the custom field labels created with WooCommerce Custom Checkout Field plugin?

Solution:
In includes/ccf.php line 302 we can wrap the 'field_name' with __() to get it auto-registered and translated, like this:

woocommerce_form_field($field['field_id'], array(
                                              'type' => $field['field_type'],
                                              'class' => array($field['field_class']),
                                              'label' => __($field['field_name']),
                                              'required' => $field_required,
                                              'placeholder' => __($field['field_placeholder']),
                                                  ), $checkout->get_value($field['field_id']));

Just remember to make sure that the default text domain is set to automatically register, and then visit the checkout page in the secondary language once to get the string registered and then you can translate it via String Translation.

This topic contains 29 replies, has 2 voices.

Last updated by jannekeW 1 year, 11 months ago.

Assigned support staff: Lauren.

Author Posts
September 28, 2017 at 11:01 am #1386072

jannekeW

Hi Lauren!
I thought my previous problem was resolved, but not entirely .....
Two items are left in the non-translation..... On the checkout page I have 2 questions that customers have to answer. They have to give permission to us to send them an invitation for a review and for giving their address to the transport company so they can receive their package. See attachments..... that part stays in dutch....
I've translated everything, but still I don't see it in the German website.... What could be the problem?

September 28, 2017 at 2:28 pm #1386370

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Thank you for contacting WPML support. I'll be happy to help you with these translations.

Can you tell me how you are adding these extra fields? Are they created by a plugin?

Also, if you temporarily switch to a default theme, do the translations display?

September 28, 2017 at 5:17 pm #1386566

jannekeW

Hi Lauren!
I added these questions through the plugin "Woocommerce Custom Checkout Field". But I translated it with your stringstranslation. (See previous attachment). I added a new screenshot from the plugin.

I don't to switch to a default theme because the website is live and I do not want to mess everything up ............ I already had enough setbacks..........

September 28, 2017 at 6:13 pm #1386632

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

To best troubleshoot the issue, please make a snapshot of your site using the Duplicator plugin: https://wordpress.org/plugins/duplicator/. This will allow me to try and duplicate the error so that I can run further tests without interrupting your live site.

Once the snapshot is complete, either upload the snapshot ZIP file and the installer.php file to a file sharing service such as Dropbox (and share the link in your reply) or right click the Duplicator links in your wp-admin and paste in your reply.

Please note: It is important to reduce the size of the package so please exclude some paths like /cache or /uploads and also exclude archives and media files.

I will also need the username and password of an account that was created BEFORE creating the duplicator package.

I will enable the next reply to be private so only you and I have access to it!

September 29, 2017 at 9:34 pm #1387649

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Thanks for sending the duplicator package, I was able to set up a copy of your site. One question I have - how did you originally add the custom field strings to the string translation table? I tried scanning the plugin, theme and even WooCommerce but I can't seem to get the strings added to our string translation table. I notice that there are some strings that seem to have the wrong language assigned, and I think this may be part of the issue.

I think this may be a compatibility issue, and once I can recreate this on your test site with minimal settings (default theme and only the checkout fields, woocommerce and WPML plugins active) I can escalate this to our compatibility team. THanks for your help with recreating this 🙂

September 30, 2017 at 10:11 am #1387779

jannekeW

Hi Lauren! Thanks again for all your help! I've added the custom field strings to the string translation table by searching for the text.... found it and translated it in the string.....

Do I have to do anything else or just wait till your compatibility team has an answer? I've also noticed that the tab of the website (Stoer & Landelijk wonen....) wasn't translated in German. I also can't find any string to it.... see attachment.

Have a nice and quiet weekend!
Janneke

October 2, 2017 at 5:15 pm #1389241

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Thanks for clarifying this for me. Is it possible that you create a custom field with the same name using a different custom checkout plugin? I am asking because in my test site, I can't find the string of the test field. Also, the plugin that you are currently using creates its own database table wp_ccf, so WPML would not be able to pull the field values from this separate table. This would explain why the string is not showing on my test site.

Also, for the site tab that is not showing translated, site tab is not showing the tagline. Did you use an SEO plugin to create the page description? If so, you will need to translate the string either via the translation table or by editing the description field on the translated editor. If you have already done that and it is not displaying, please open a separate ticket for that particular issue. This is just to avoid confusion by having too many issues combined in one ticket.

Please let me know if you could have created the same checkout field with an earlier plugin. Also, I will send this to our compatibility team since I was able to see that this plugin is not compatible with WPML since it creates a separate database table. I'll let you know as soon as I have more information, but please keep in mind that it may depend on how quickly the plugin author responds to our team.

October 3, 2017 at 9:02 am #1389757

jannekeW

Hi Lauren! Thanks for your answer.

For the custom field in the checkout I only used Custom Checkout Field, nothing else. I found the string by using/copying a piece of the custom text I made and paste it in the stringtranslation. The page description is made in the plugin All in one SEP pack. I don't see a string with the text (only descriptions and all other from All in one seo pack) and I don't see/there isn't a translation editor...... I found this on the semperplugings-website: hidden link

I can't really go to deep into it, just read it casual, not really feeling to well because of a hospital treatment yesterday....
Jumping into bed again now...
Have a nice day!
Janneke

October 3, 2017 at 9:32 am #1389802

jannekeW

I also see that WPML Page Builders is deactivated.... could that be a problem?

October 6, 2017 at 7:51 pm #1394141

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Hi Janneke, our compatibility team has reached out to the author to try and find a permanent fix, but in the meantime, they have come up with this workaround:

In includes/ccf.php line 302 we can wrap the 'field_name' with __() to get it auto-registered and translated, like this:

woocommerce_form_field($field['field_id'], array(
                                              'type' => $field['field_type'],
                                              'class' => array($field['field_class']),
                                              'label' => __($field['field_name']),
                                              'required' => $field_required,
                                              'placeholder' => __($field['field_placeholder']),
                                                  ), $checkout->get_value($field['field_id']));

Just remember to visit the checkout page in the secondary language once, to get the string registered and then you can translate it via String Translation. Please let me know if this works for you.

October 7, 2017 at 12:04 pm #1394356

jannekeW

Hi Lauren!

You mean the author of Custom Checkout Field?
The script you send me is really Chinese to me. I don't know what to do with it..... Could you please explain to me what I have to do and where to do it? Don't speak "computer" that wel....

In the last couple of days I've scanned all the themes for strings again to search the missing ones and to determine which ones I can delete to save some memory (of course also deleted strings that were translated... stupid me....). I'm often at the maximal of my CPU sources.

I have found and translated some strings but there are some that I still need to translate. But there are still 5 strings (+ the ones in the custom checkout field = 7) that I can not find. In the attachment you will find the examples. Maybe you know where I can find them and how to solve this ..... I don't have a printscreen from the 5th, but it is "checkout" on the same place as image 1 when I put something in the cart.

Love to hear from you!
Have a nice weekend!
Janneke

October 9, 2017 at 1:53 pm #1395457

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Hi Janneke, I'll be happy to make these changes for you, I will just need FTP access. I"ve marked the next reply as private so you can share FTP credentials. Thanks!

October 9, 2017 at 8:12 pm #1395913

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Thanks so much for sending these screenshots to help me better understand. Unfortunately, neither the FTP nor the WordPress credentials are working for me, and I will need those in order to troubleshoot the translations. Please double check and update as needed, I have marked the next reply as private.

I also hope you are feeling better soon!

October 10, 2017 at 1:34 pm #1396820

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Thanks for sending updated credentials. The FTP credentials did not work but I was able to set up a temporary access via the Direct Admin. Can you please tell me the file path for your WordPress files? I checked in all of the folders but could not see them. I need access to the /includes/ folder so I can add the workaround for the checkout fields.

I also tried viewing your site to see the untralsated strings but when I try to view the checkout page, I get an error that the site is out of resources. Please see screenshot attached.

Lastly, please go to WPML -> Theme and plugin localization and select the option to translating using string translation and .mo files. I think that some of your translations may be in the .mo files and with the .mo files, they aren't showing. Let me know the results of that.

I'd like to keep the focus of this ticket on resolving the custom checkout fields. Once that is resolved, it will be best to open a new ticket for the WooCommerce string translations, just to avoid confusion with multiple issues being in one thread.

October 10, 2017 at 2:16 pm #1396910

jannekeW

Hi Lauren!
Thanks for your efforts! I think is hidden link (i hope it is..... my knowledge doesn't go that far....)

The error could be that I was uploading a lot to Cloudinary. I had same error during the weekend when there was a big security scan. But I also increased my CPU saturday from 4 to 6 cores an from 2 GB tot 4 GB..... And when several people (you and I?) are on it the same time it goes wrong...... Also the scanning and bulk deleting a lot of strings was a bit to much... or couldn't that be the case? Just trying to think logical......

Got this message on hidden link: You have reached entry processes (number of simultaneously running php and cgi scripts, as well as cron jobs and shell sessions) limit 238 times

I hope that it will be over soon.......I will also ask Cloudinary if it could me because them......

You say: select the option to translating using string translation and .mo files. I think that some of your translations may be in the .mo files and WITH the .mo files, they aren't showing.
- I did that now, but isn't this contradictory? Shouldn't they be showing then WITHOUT the .mo files the way it was?

Do I have to scan everything now again to find the missing strings from the rest of the website to get them out of the .mo files???

Big hug, Janneke