Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#38788 closed enhancement (fixed)

Make get_available_languages() filtrable

Reported by: yoavf's profile yoavf Owned by: pento's profile pento
Milestone: 4.7 Priority: normal
Severity: normal Version: 4.7
Component: I18N Keywords: has-patch
Focuses: Cc:

Description (last modified by yoavf)

When a user object is saved using edit_user() (i.e, after editing the user settings) WP will discard (and replace with en_US) any submitted value for the new user locale meta if it is not part of the array returned by get_available_languages()

get_available_languages() works by scanning the language folder for .mo files. In some use cases, language files might not exist for a locale, named in a different way, or maybe stored elsewhere. get_available_languages() results should be filtrable.

FWIW: we need this filter (or an alternate solution) to merge the new user locale setting and locale switching to WP.com.

Attachments (1)

38788.diff (1.1 KB) - added by yoavf 8 years ago.

Download all attachments as: .zip

Change History (11)

@yoavf
8 years ago

#1 @yoavf
8 years ago

  • Description modified (diff)

#2 @yoavf
8 years ago

  • Description modified (diff)

#4 @pento
8 years ago

  • Milestone changed from Awaiting Review to 4.7
  • Owner set to pento
  • Status changed from new to assigned

#5 follow-up: @pento
8 years ago

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

In 39235:

I18N: Add the get_available_languages filter.

Sometimes, a language file may not exist in exactly the format or location that get_available_languages() expects it to be in - for sites with this level of customisation, they need to be able to add their own language files to the list of those available.

Props yoavf.
Fixes #38788.

#6 @ocean90
8 years ago

In 39244:

Docs: Apply documentation standards to the new get_available_languages filter.

See #38788.

#7 in reply to: ↑ 5 ; follow-up: @ocean90
8 years ago

Replying to pento:

Sometimes, a language file may not exist in exactly the format or location that get_available_languages() expects it to be in

For this case, wouldn't it make more sense to have a pre_get_available_languages filter instead?

#8 in reply to: ↑ 7 @pento
8 years ago

Replying to ocean90:

For this case, wouldn't it make more sense to have a pre_get_available_languages filter instead?

Either works, I think. @yoavf is doing the migration, so I went with his recommendation.

#9 @yoavf
8 years ago

@ocean90 no strong preference. I think that the current filter serves this purpose, but potentially another purpose of keeping the original list but excluding specific languages.

#10 @neoxx
8 years ago

#38591 was marked as a duplicate.

Note: See TracTickets for help on using tickets.