1: <?php
2: /*
3: You may not change or alter any portion of this comment or credits
4: of supporting developers from this source code or any supporting source code
5: which is considered copyrighted (c) material of the original comment or credit authors.
6:
7: This program is distributed in the hope that it will be useful,
8: but WITHOUT ANY WARRANTY; without even the implied warranty of
9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: namespace Xoops\Core\Lists;
13:
14: use Punic\Data;
15: use Punic\Language;
16:
17: /**
18: * Locale - provide list of locale names
19: *
20: * @category Xoops\Core\Lists\Locale
21: * @package Xoops\Core
22: * @author Richard Griffith <richard@geekwright.com>
23: * @copyright 2015 XOOPS Project (http://xoops.org)/
24: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
25: * @link http://xoops.org
26: */
27: class Locale extends ListAbstract
28: {
29: /**
30: * gets list of locales
31: *
32: * @param boolean $showInCodeLanguage true to show a code's name in the language the code represents
33: *
34: * @return array
35: */
36: public static function getList($showInCodeLanguage = true)
37: {
38: $locales = Data::getAvailableLocales();
39: $languages = array();
40: foreach ($locales as $locale) {
41: $key = \Xoops\Locale::normalizeLocale($locale);
42: $languages[$key] = Language::getName($locale, ($showInCodeLanguage ? $locale : null));
43: }
44:
45: \XoopsLocale::asort($languages);
46:
47: return $languages;
48: }
49: }
50: