Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default field group label cannot be changed using gettext #2413

Open
3 tasks done
dwanjuki opened this issue Mar 17, 2023 · 2 comments
Open
3 tasks done

Default field group label cannot be changed using gettext #2413

dwanjuki opened this issue Mar 17, 2023 · 2 comments

Comments

@dwanjuki
Copy link
Contributor

Describe the bug
It is not possible to change the default "More Information" field group label on the checkout page using a gettext filter.

To Reproduce
Steps to reproduce the behavior:

  1. Create user fields using code and add them to the default group.
  2. Add a gettext filter callback to replace the default label text: "More Information".
  3. Visit the checkout page.
  4. The "More Information" text is not changed.

Expected behavior
The default field group level label is replaced by the text returned by the gettext filter callback.

Isolating the problem (mark completed items with an [x]):

  • I have deactivated other plugins and confirmed this bug occurs when only Paid Memberships Pro plugin is active.
  • This bug happens with a default WordPress theme active, or Memberlite.
  • I can reproduce this bug consistently using the steps above.

WordPress Environment

  • WordPress 6.1.1
  • PHP 8.0.28
  • PMPro 2.10.3
  • Memberlite 4.5.4.1
@JarrydLong
Copy link
Contributor

Just making a note here that this can be changed with a filter instead apply_filters( 'pmpro_default_field_group_label', __( 'More Information','paid-memberships-pro' ) )

@nourhammoury
Copy link

nourhammoury commented Aug 3, 2023

i was able to translate it using the following approach. this is the only thing that worked for me.

`function translate_checkout_fields($html) {
$translations = array(
"More Information" => "Translation-HERE",
);

$language = get_locale();

if ($language == "ar") {
$translated_html = str_replace(
array_keys($translations),
array_values($translations),
$html
);
} else {
$translated_html = $html;

if ($language == "en") {
  $translated_html = str_replace(
    array_keys($translations),
    array_values($translations),
    $html,
    array('case_insensitive' => true)
  );
}

}

return $translated_html;
}

add_filter('the_content', 'translate_checkout_fields');`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants