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: | ocean90 | Owned by: | ocean90 |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.7 |
| Component: | I18N | Version: | 4.6 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
We should check the return value of
glob()before merging it becauseglob()returnsfalsein case of a failure.