Translating Custom Registration/Profile Fields

My website is available in numerous different languages.

I’m currently trying to translate the Register form and My Profile pages. I am using WPML.

The standard s2Member strings are picked up by WPML but it doesn’t recognise my custom fields as translatable strings.

For example here: https://uglymugs.ie/pt-br/register/ (That is a paypal pro form I’m using there)

I can translate username and email as they are standard s2member fields. But I cannot translate the rest of the form which is custom fields.

Is there a way to translate custom fields?

Thanks

Hi Lucy,

As this is s2M Pro-form, you can create a custom template, which is a PHP file, actually. There you can build translations with standard i18n functions, and custom text domain, so you can create *.po file. And this will give you possibility to translate strings manually, in PoEdit. Not easy to do, so use only if no other way.

Another, not so hard way is to create custom plugin for that. Still not easy for you, but I am curious to do such plugin. Again, if you really need and have no other way.

Hi,

Thanks. You helped me out before with another thing I needed I remember and did a great job.

Would you be interested in doing this for me as a paid job?

Thanks

Lucy

I remember :slight_smile: I am happy that you remember too, and thanks about evaluating my work!

You are still in my TDL, just post there, I will review, as usual.

Done. Thank you very much :slight_smile:

Just for info, this is the plugin I created to synchronize s2M and WPML.

I thought I should share how I managed to create a translation of custom fields and their labels on bilingual web site.
The problem with custom fields’ labels is that in the s2member classes the labels generated as plain text, not localized, thus it is not possible to translate them by adding custom labels to the .pot / .po file and generating .mo file for your language.
The way around it (until the s2member team does localization of labels) to replace non-localized custom fields labels with localized by using javascript in custom templates.
Here is tutorial how to create custom templates:

Add this script at the bottom of the template (amend using your own field labels and section titles) and you will be able to add all them to the pot / .po file:

var address = document.getElementById(‘s2member-pro-paypal-checkout-form-custom-reg-field-address-divider-section’);
var streetaddress = document.getElementById(‘s2member-pro-paypal-checkout-form-custom-reg-field-address-label’);
var city = document.getElementById(‘s2member-pro-paypal-checkout-form-custom-reg-field-city-label’);
var postcode = document.getElementById(‘s2member-pro-paypal-checkout-form-custom-reg-field-postcode-label’);
var country = document.getElementById(‘s2member-pro-paypal-checkout-form-custom-reg-field-country-label’);
// localized replacements
address.innerHTML = ‘<?php echo _x ("Postal Address", "s2member-front", "s2member"); ?>’;
streetaddress.innerHTML = ‘<?php echo _x ("Address", "s2member-front", "s2member"); ?>’;
city.innerHTML = ‘<?php echo _x ("City", "s2member-front", "s2member"); ?>’;
postcode.innerHTML = ‘<?php echo _x ("Postal Code", "s2member-front", "s2member"); ?>’;
country.innerHTML = ‘<?php echo _x ("Country", "s2member-front", "s2member"); ?>’;

And here how to localize the options labels in the select:
add_action(“ws_plugin__s2member_before_custom_field_gen”, “my_dynamic_field_options”);
function my_dynamic_field_options ($vars = array()) {
$_field = &$vars["__refs"]["_field"];
if ($_field[“id”] === “age_group”) {
$_field[“options”] = “Not selected|” . _x (‘Select Age Group’, ‘s2member-front’, ‘s2member’) . “|default” . “\n”;
$_field[“options”] .= “Under 20|” . _x (‘Under 20’, ‘s2member-front’, ‘s2member’) . “\n”;
$_field[“options”] .= “20-30|” . _x (‘20-30’, ‘s2member-front’, ‘s2member’) . “\n”;
$_field[“options”] .= “31-40|” . _x (‘31-40’, ‘s2member-front’, ‘s2member’) . “\n”;
$_field[“options”] .= “41-50|” . _x (‘41-50’, ‘s2member-front’, ‘s2member’) . “\n”;
$_field[“options”] .= “51-60|” . _x (‘51-60’, ‘s2member-front’, ‘s2member’) . “\n”;
$_field[“options”] .= “61-70|” . _x (‘61-70’, ‘s2member-front’, ‘s2member’) . “\n”;
$_field[“options”] .= “71-80|” . _x (‘71-80’, ‘s2member-front’, ‘s2member’) . “\n”;
$_field[“options”] .= “Over 80|” . _x (‘Over 80’, ‘s2member-front’, ‘s2member’);

}

}

Hi,

is there still no build in solution for that issue? Seems to be a quick change for the s2member plugin isn’t it?