Skip to:
Content

BuddyPress.org

Opened 7 months ago

Closed 7 months ago

#9187 closed defect (bug) (fixed)

Custom BuddyPress translation files are no more loaded since WP 4.6

Reported by: imath's profile imath Owned by: imath's profile imath
Milestone: 14.0.0 Priority: strategic
Severity: major Version: 1.0
Component: Core Keywords: has-patch
Cc:

Description

Reviewing @vapvarun's PR about documenting how to use custom labels (etc..) made me remember we lost this very important feature for our plugin when WP's _load_textdomain_just_in_time() function was introduced in version 4.6. I remember I was a bit mad at it!

FWIW, here's the ticket https://core.trac.wordpress.org/ticket/37819 I opened about it 8 years ago.

We need something approaching back: it's a very important way to customize BuddyPress even for en_US communities.

Change History (7)

This ticket was mentioned in PR #316 on buddypress/buddypress by imath.


7 months ago
#1

  • Keywords has-patch added; needs-patch removed

Use the 'load_translation_file' filter to check custom file locations for the buddypress text domain.

NB: this filter was introduced by WordPress in version 6.5.

If there's a buddypress-xx_XX.mo (where xx_XX is the locale code) file into one of the following directories, it will be used to replace the default one (WordPress.org Plugin Directory / GlotPress):

  1. /wp-content/languages/plugins/buddypress (added in 14.0.0)
  2. /wp-content/languages/buddypress
  3. /wp-content/languages

Trac ticket: https://buddypress.trac.wordpress.org/ticket/9187

imath commented on PR #316:


7 months ago
#2

FYI, I've also added a function to override default JavaScript translation files used in BP Blocks.

#3 @imath
7 months ago

  • Owner set to imath
  • Resolution set to fixed
  • Status changed from new to closed

In 13936:

i18n: bring back custom locations for translation files

Prior to WordPress 4.6, it was possible to completely override the translation file with a custom one from one of the 'buddypress_locale_locations' filterable list items.

With WordPress 6.5 latest improvements about l10n, we are now able to bring these back. Making it easier for users to customize every BuddyPress strings should help them build match their community needs (e.g.: using sport/school/working/any other wording).

3 functions has been introduced:

  • bp_get_custom_translation_file() is looking for a file name into 'buddypress_locale_locations' filterable list items.
  • bp_load_custom_translation_file() is the 'load_translation_file' filter callback for regular translation files.
  • bp_load_custom_script_translation_file() is the 'load_script_translation_file' filter callback for JavaScript translation files.

The bp_core_load_buddypress_textdomain() function has been deprecated as it was pretty useless since WordPress 4.6.

Props espellcaste

Fixes #9187
Closes https://github.com/buddypress/buddypress/pull/316

#4 @imath
7 months ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

#5 @imath
7 months ago

We actually need to keep bp_core_load_buddypress_textdomain() so that it's possible to use a custom en_US translation file to customize BuddyPress texts to match specific community needs.

This ticket was mentioned in PR #322 on buddypress/buddypress by imath.


7 months ago
#6

If we don't need bp_core_load_buddypress_textdomain() for the regular translation usage, when an advanced user is using a custom en_US language file for BuddyPress, we absolutely need it to load this specific file.

Trac ticket: https://buddypress.trac.wordpress.org/ticket/9187

#7 @imath
7 months ago

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

In 13941:

Make sure default en_US BuddyPress strings can be override

Restore bp_core_load_buddypress_textdomain() so that it's possible to customize all BuddyPress default strings with a custom buddypress-en_US.mo translation file.

Fixes #9187
Closes https://github.com/buddypress/buddypress/pull/322

Note: See TracTickets for help on using tickets.