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

Last updated by Radu 3 months, 1 week ago.

Assigned support staff: Radu.

Author Posts
June 24, 2019 at 10:02 pm #4079915

philippeB-41

Hello, I am trying to: Translate the options of my custom buddypress xprofile fields. I managed to translate all the profile fields names and descriptions using the available doc (https://wpml.org/documentation/related-projects/buddypress-multilingual/) by download the po file for the BuddyPress Multilingual domain et reuploading it with translations (see attached screenshots). How, although I provided translations for the options, they don't seem to be translated when I go to my profile either on the view or edit pages.

I tried the 3 different settings in the WPML theme and plugin localization options without any luck (see second screen)

After several hours trying a few other options, I am now officially desperate for help!

June 25, 2019 at 9:44 am #4082811

Radu
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+03:00)

Hey Philippe,

Thank you for reaching out the WPML support! Don't worry, we'll take care of this. It's really helpful that you shared the things that you tried to do so far.
Can you tell me how did you add these buddypress xprofile fields, please? Did you follow the instructions from here hidden link? Also, is there any chance that you could give me access to the dashboard area of your website so I can have a look at this custom field and see what can be done in order to translate it, please? The next reply is set to be private so you can safely send me the credentials.

Thanks,
Radu

June 27, 2019 at 6:52 am #4096991

Radu
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+03:00)

Hey Philippe,

I looked for this a bit more and it seems that there was another user that asked about this and one of my colleagues came out with a piece of code to make the profile fields available for translation. Can you add the code from here https://wpml.org/forums/topic/how-can-i-translate-the-content-of-a-custom-field-in-buddypress/#post-2426866 to your website (you can add it to the functions.php file of your theme) and tell me if you can see the profile values available for translation in String translation now, please?

Thanks,
Radu

Thanks,
Radu

June 27, 2019 at 8:48 am #4098053

philippeB-41

Hello,

I just tried without anyluck. Althgough I suspect that it's not the values which are causing an issues but the field options for checkboxes and radios. In addition, I do see them in string translation but they just don't seem to be applied...

Maybe there is an adaptation of the code you provided that could work?

June 28, 2019 at 8:52 am #4105765

Radu
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+03:00)

Philippe,

I accessed this page where I can see the custom fields you created hidden link. However, when I try to access the English version of it right here hidden link, I get a 404 page. Can you tell me if you can access for your account, please?
I copied the Gender custom field on my website, added the translation for the radio buttons in String translation and everything works fine when I check the field in the secondary language. Can you tell me if you installed the BuddyPress Multilingual plugin after you created the custom fields, please? I'm thinking that maybe this is why they didn't get registered automatically on your website (while everything worked fine when I tried to do the same).

Thanks,
Radu

June 28, 2019 at 11:08 am #4106775

philippeB-41

"Can you tell me if you can access for your account, please?"

> It's normal, I left the en version of the member page as a draft, which results in the 404 error

"Can you tell me if you installed the BuddyPress Multilingual plugin after you created the custom fields, please?"

> I did, but I think the string register just fine.

Actually, I have some good news, I managed to fix my issue using the following method:

- I realised that we had created a custom filter applied to the checkbox/radio options filters which prevented the plugin to work it's magic.

I added manually some code to fix it:

 
// I added this code taken from bp multilingual to keep the options translations
    $_context = 'Buddypress Multilingual';
    $_field_string_prefix = 'profile field ';
    $_group_string_prefix = 'profile group ';
    $sanitized_string = bpml_sanitize_string_name( $value->name, 30 );
    $label = "{$_field_string_prefix}{$id} - option '{$sanitized_string}'";
    $translation_ready_name = stripslashes( apply_filters( 'wpml_translate_single_string', $value->name, $_context,
    $label . ' name' ) ); 

However, I realized I had another issue due to the fact that I don't see any WPML filter applied bp_get_profile_field_data, which could be useful when the field is of type radio or checkbox with predefined values. Can you confirm this?

So far, I came up with a similar fix but it needs to be applied to each field which is suboptimal. With it, I managed to use the translations provided in String Translations, see below:

  
            $data = bp_get_profile_field_data( array( 'field' => 'My Field', 'user_id' => $user_id ) );
            $sanitized_string = bpml_sanitize_string_name( $data, 30 );
            $translated_string = apply_filters( 'wpml_translate_single_string', $data, 'Buddypress Multilingual', "profile field 579 - option '{$sanitized_string}' name" ); 
July 1, 2019 at 11:09 am #4118187

Radu
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+03:00)

Hey Philippe,

Can you give me a few more details about the custom filter applied to the checkbox/radio options filters which prevented the plugin to work it's magic, please? Also, what's the other issue you have due to the bp_get_profile_field_data filter that's not used? Is it still related to checkboxes/radio buttons? I tried to create a new custom field on my side and it still worked very well, without any other custom code.

Thanks,
Radu

July 8, 2019 at 7:53 am #4159647

philippeB-41

Hi Radu,

Sorry for the late reply.

Actually, it's not really a custom filter but we defined our own edit_field_html function for radio since the filter provided by BuddyPress did not provide enough flexibility for us. This broke the compatibility with third-party plugin on that function.

Well, it seems that when I call bp_get_profile_field_data, I always get the data in the original language for radios, this is why I added some custom code to apply wpml filter "again".

July 9, 2019 at 7:35 am #4168141

Radu
Supporter

Languages: English (English )

Timezone: Europe/Bucharest (GMT+03:00)

Hey Philippe,

Is everything back to normal, now that you added the additional custom code that you mentioned in the last message?

Thanks,
Radu

The topic ‘[Closed] Not able to translate buddypress xProfile fields options with string translation’ is closed to new replies.