Opened 10 years ago
Closed 10 years ago
#38590 closed defect (bug) (fixed)
Don't use `get_available_languages()` in `_load_textdomain_just_in_time()`
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.7 | Priority: | normal |
| Severity: | normal | Version: | 4.6 |
| Component: | I18N | Keywords: | has-patch |
| Focuses: | Cc: |
Description
get_available_languages() has been introduced in #11774 and is only designed to work with translations for core IMO.
Since [37415] it's also used to retrieve translations in the plugin/theme directory of WP_LANG_DIR.
get_available_languages() does three strpos() checks to prevent returning language codes like admin-zh_TW, continents-cities-zh_TW or ms-zh_TW.
Using get_available_languages() for plugins/themes will not return language codes (see @return tag). It returns the text domain and the language code of a file. But only if a plugin/theme doesn't start with admin- or ms-.
Instead of using get_available_languages() in _load_textdomain_just_in_time() a direct call to glob() should be sufficient.
We should check the return value of
glob()before merging it becauseglob()returnsfalsein case of a failure.