| @@ -69,14 +69,16 @@ | ||
| 69 | 69 | * @return self The Language object. |
| 70 | 70 | */ |
| 71 | 71 | public static function getInstance($lang = null) |
| 72 | 72 | { |
| 73 | - if (!isset(static::$instances[$lang])) | |
| 73 | + $key = (string) $lang; | |
| 74 | + | |
| 75 | + if (!isset(static::$instances[$key])) | |
| 74 | 76 | { |
| 75 | - static::$instances[$lang] = new static($lang); | |
| 77 | + static::$instances[$key] = new static($lang); | |
| 76 | 78 | } |
| 77 | 79 | |
| 78 | - return static::$instances[$lang]; | |
| 80 | + return static::$instances[$key]; | |
| 79 | 81 | } |
| 80 | 82 | |
| 81 | 83 | /** |
| 82 | 84 | * Loads a single language file. This method doesn't update the |
| @@ -498,10 +500,15 @@ | ||
| 498 | 500 | * @since 10.1.9 |
| 499 | 501 | */ |
| 500 | 502 | public static function getKnownLanguages() |
| 501 | 503 | { |
| 502 | - // get installed languages | |
| 503 | - $list = get_available_languages(); | |
| 504 | + /** | |
| 505 | + * Get installed languages. | |
| 506 | + * | |
| 507 | + * @since 10.1.55 Get rid of the keys because third-party plugins might attach | |
| 508 | + * custom languages by using non-integer keys. | |
| 509 | + */ | |
| 510 | + $list = array_values(get_available_languages()); | |
| 504 | 511 | |
| 505 | 512 | // if the default US lang is in the array, remove it |
| 506 | 513 | if ($index = array_search('en_US', $list)) |
| 507 | 514 | { |