Make WordPress Core

Opened 7 years ago

Closed 5 years ago

#38736 closed enhancement (fixed)

Add $domain parameter to translate_user_role()

Reported by: johnjamesjacoby's profile johnjamesjacoby Owned by: ocean90's profile ocean90
Milestone: 5.2 Priority: normal
Severity: normal Version: 4.7
Component: Role/Capability Keywords: has-patch
Focuses: Cc:

Description

The translate_user_role() function currently only works with WordPress's built-in user roles.

For a plugin like bbPress, it cannot pass the bbpress text domain through to translate_with_gettext_context(), meaning it's roles can only be translated as part of the default text domain.

This becomes more of an issue in WordPress 4.7 due to load-order changes between roles & locales.

Patch imminent.

Attachments (2)

38736.patch (798 bytes) - added by johnjamesjacoby 7 years ago.
Add $domain parameter
38736.2.diff (919 bytes) - added by ocean90 5 years ago.

Download all attachments as: .zip

Change History (6)

@johnjamesjacoby
7 years ago

Add $domain parameter

#1 follow-up: @jdgrimes
7 years ago

Say I have a plugin that uses translate_user_role() for each of the roles in WordPress, how do I know which textdomain to pass for each role? (I know this is maybe a separate issue from this ticket, but I hadn't considered it before.)

#2 in reply to: ↑ 1 @johnjamesjacoby
7 years ago

Replying to jdgrimes:

Say I have a plugin that uses translate_user_role() for each of the roles in WordPress, how do I know which textdomain to pass for each role? (I know this is maybe a separate issue from this ticket, but I hadn't considered it before.)

Good question. Right now, I don't have an answer, since there are no role-groups or domain key.

If a plugin included its own version of this function (as bbPress now does) the problem you describe will still exist for anything trying to loop through all of the roles at once.

@ocean90
5 years ago

#3 @ocean90
5 years ago

  • Keywords 2nd-opinion removed
  • Milestone changed from Awaiting Review to 5.2
  • Owner set to ocean90
  • Status changed from new to accepted

#4 @ocean90
5 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 44830:

I18N: Add $domain argument to translate_user_role().

The text domain is optional and gets passed to translate_with_gettext_context().

Props johnjamesjacoby .
Fixes #38736.

Note: See TracTickets for help on using tickets.