| @@ 1462-1480 (lines=19) @@ | ||
| 1459 | * |
|
| 1460 | * @return array Map of locale code => name |
|
| 1461 | */ |
|
| 1462 | public function getLocales() |
|
| 1463 | { |
|
| 1464 | // Cache by locale |
|
| 1465 | $locale = i18n::get_locale(); |
|
| 1466 | if (!empty(static::$cache_locales[$locale])) { |
|
| 1467 | return static::$cache_locales[$locale]; |
|
| 1468 | } |
|
| 1469 | ||
| 1470 | // Localise all locales |
|
| 1471 | $locales = $this->config()->get('locales'); |
|
| 1472 | $localised = []; |
|
| 1473 | foreach ($locales as $code => $default) { |
|
| 1474 | $localised[$code] = $this->localeName($code); |
|
| 1475 | } |
|
| 1476 | ||
| 1477 | // Save cache |
|
| 1478 | static::$cache_locales[$locale] = $localised; |
|
| 1479 | return $localised; |
|
| 1480 | } |
|
| 1481 | ||
| 1482 | /** |
|
| 1483 | * Cache of localised languages, keyed by locale localised in |
|
| @@ 1494-1512 (lines=19) @@ | ||
| 1491 | * |
|
| 1492 | * @return array Map of language code => name |
|
| 1493 | */ |
|
| 1494 | public function getLanguages() |
|
| 1495 | { |
|
| 1496 | // Cache by locale |
|
| 1497 | $locale = i18n::get_locale(); |
|
| 1498 | if (!empty(static::$cache_languages[$locale])) { |
|
| 1499 | return static::$cache_languages[$locale]; |
|
| 1500 | } |
|
| 1501 | ||
| 1502 | // Localise all languages |
|
| 1503 | $languages = $this->config()->get('languages'); |
|
| 1504 | $localised = []; |
|
| 1505 | foreach ($languages as $code => $default) { |
|
| 1506 | $localised[$code] = $this->languageName($code); |
|
| 1507 | } |
|
| 1508 | ||
| 1509 | // Save cache |
|
| 1510 | static::$cache_languages[$locale] = $localised; |
|
| 1511 | return $localised; |
|
| 1512 | } |
|
| 1513 | ||
| 1514 | /** |
|
| 1515 | * Get name of locale |
|