Make WordPress Core

Opened 8 years ago

Closed 5 years ago

#37539 closed enhancement (fixed)

translate_user_role only working in admin

Reported by: keraweb's profile keraweb Owned by: ocean90's profile ocean90
Milestone: 5.2 Priority: normal
Severity: normal Version: 4.0
Component: I18N Keywords: has-patch
Focuses: Cc:

Description

The user role translations are only available in the admin.
I'd like to see them available in the front-end aswell.

This is not working:

if ( ! is_admin() ) {
        load_textdomain( 'default', WP_LANG_DIR . '/admin-' . get_locale() . '.mo' );
}

Attachments (2)

37539.patch (710 bytes) - added by keraweb 8 years ago.
Locale role gettext calls right below translate_user_role() in l10n.php
37539.2.diff (1.5 KB) - added by ocean90 5 years ago.

Download all attachments as: .zip

Change History (10)

#1 follow-up: @ocean90
8 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release
  • Type changed from feature request to enhancement

To make them available on the front end we have to put the user roles into a /wp-includes file.

#2 follow-up: @keraweb
8 years ago

Not only that.
The default .mo files for the front-end doesn't contain the role translations at all.

Found a workaround:

add_action( 'init', 'load_admin_textdomain_in_front' )
function load_admin_textdomain_in_front() {
    if ( ! is_admin() ) {
        load_textdomain( 'default', WP_LANG_DIR . '/admin-' . get_locale() . '.mo' );
    }
}

#3 in reply to: ↑ 2 ; follow-up: @ocean90
8 years ago

Replying to keraweb:

The default .mo files for the front-end doesn't contain the role translations at all.

That's why we have to move them. :)

#4 in reply to: ↑ 3 @keraweb
8 years ago

Replying to ocean90:

Replying to keraweb:

The default .mo files for the front-end doesn't contain the role translations at all.

That's why we have to move them. :)

Oh yeah of course -.- sorry!

#5 in reply to: ↑ 1 @keraweb
8 years ago

Replying to ocean90:

To make them available on the front end we have to put the user roles into a /wp-includes file.

Why not simply within the translate_user_role function?
Seems like the most logical location to me.

EDIT: Nevermind, then this would be executed with every call.. Maybe outside this function?

Last edited 8 years ago by keraweb (previous) (diff)

@keraweb
8 years ago

Locale role gettext calls right below translate_user_role() in l10n.php

#6 @keraweb
8 years ago

  • Keywords dev-feedback has-patch added; needs-patch removed

@ocean90
5 years ago

#7 @ocean90
5 years ago

  • Keywords dev-feedback removed
  • Milestone changed from Future Release to 5.2
  • Owner set to ocean90
  • Status changed from new to accepted

37539.2.diff moves the strings to /wp-includes/capabilities.php.

#8 @SergeyBiryukov
5 years ago

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

In 44976:

I18N: Move the strings for default user roles to wp-includes/capabilities.php, to make the translations available on the front end as well.

Props keraweb, ocean90.
Fixes #37539.

Note: See TracTickets for help on using tickets.