Returns list of locale language names in a locale
@param string[]|null $codes the list of codes to get names, the empty value means all codes
@param string|null $in_code optional format locale code
@return array
184543
public static function localeNames($codes, $in_code = null)
    {
        $list = [];
        $codes = $codes ?: static::codes();
        foreach ($codes as $code) {
            $list[$code] = static::localeName($code, $in_code);
        }

        return $list;
    }
713619
public static function getCodesByNames($names=array())
	{
		if (!($gdb = self::getGeoDBO()))
		{
			return array();
		}

		$names = array_map('strtolower', $names);
		foreach ($names as $k => $name)
		{
			$names[$k] = $gdb->quote($name);
		}

		$gdb->setQuery("SELECT DISTINCT name, code FROM countries WHERE LOWER(name) IN (" . implode(",", $names) . ")");
		$values = $gdb->loadAssocList('name');
		if (!is_array($values))
		{
			$values = array();
		}
		return $values;
	}
1228792
public static function normalizeLangCode($langCode, $strict = false)
    {
        $langList = static::activeLanguagesArray();
        if ($strict) {
            $result = false;
        } else {
            $result = $langCode;
        }
        foreach ($langList as $lang) {
            if ($lang['code_full'] == $langCode || $lang['code2'] == $langCode || $lang['code3'] == $langCode) {
                $result = $lang['code_full'];
            } elseif (strtolower($lang['name_en']) == strtolower($langCode)) {
                $result = $lang['code_full'];
            } elseif (strtolower($lang['name_orig']) == strtolower($langCode)) {
                $result = $lang['code_full'];
            }
        }
        return $result;
    }
583676
public static function localeName($code, $in_code = null)
    {
        $code = str_replace('-', '_', $code);
        $in_code = str_replace('-', '_', $in_code ?: \Locale::getDefault());

        static $languages;
        if (!isset($languages[$in_code])) {
            $languages[$in_code] = [];
            $resource = \ResourceBundle::create($in_code, 'ICUDATA-lang')->get('Languages');
            foreach($resource as $name => $value) {
                $languages[$in_code][$name] = $value;
            }
        }

        return isset($languages[$in_code][$code])
            ? $languages[$in_code][$code]
            : \Locale::getDisplayName($code, $in_code);
    }
97085
public static function GetNameForCode($code, $args = null, $_ = null)
  {
    if (!array_key_exists($code, static::$errors_arr)) {
      return false;
    }

    $str = static::$errors_arr[$code];

    if (!is_null($args)) {
      if (!is_array($args)) {
        $args = array_slice(func_get_args(), 1);
      }

      array_unshift($args, $str);

      return call_user_func_array('sprintf', $args);
    }

    return $str;
  }
913051
public static function getLanguage($code = 'default')
    {
        if ($code == 'default') {
            $code = App::getLocale();
        }

        return self::addNames([$code])[$code];
    }
587077
public function get($code)
    {
        $result = null;
        $this->hook->attach('language.get.before', $code, $result, $this);

        if (isset($result)) {
            return (array) $result;
        }

        $list = $this->getList();
        $result = isset($list[$code]) ? $list[$code] : array();

        $this->hook->attach('language.get.after', $code, $result, $this);
        return (array) $result;
    }
407284
protected function getCode($code)
    {
        if (is_array($code)) {
            return $this->getCodeArray($code);
        }

        return $this->get($code);
    }
1368650
public function getLanguageValues($asArray = null)
    {
        if (!$this->owner->getIsNewRecord() && $this->_languageValues === null) {
            $this->_languageValues = [];

            /* @var ActiveRecord $language */
            foreach ($this->owner->{$this->languageRelation} as $language) {
                $this->_languageValues[] = $language->getAttribute($this->languageValueAttribute);
            }
        }

        if ($asArray === null) {
            $asArray = $this->languageValuesAsArray;
        }

        if ($asArray) {
            return $this->_languageValues === null ? [] : $this->_languageValues;
        } else {
            return $this->_languageValues === null ? '' : implode(', ', $this->_languageValues);
        }
    }
637280
function translate ($code)
    {
        if (preg_match_all("/<\?_\(\"(.*)\"\)\?>/siU", $code, $matches, PREG_SET_ORDER)) {
            foreach ($matches as $match) {
                if (isset($match[1])) {
                    $code = str_replace($match[0], gettext(stripslashes($match[1])), $code);
                }
            }
        }
        return $code;
    }
383676
public function selectLanguage($langcode = null)
    {
        $languages = array();

        foreach ($this->language->getList() as $code => $language) {
            if ($code === 'en' || is_file($this->translation->getFile($code))) {
                $languages[$code] = $language['name'];
            }
        }

        if (count($languages) < 2 && !isset($langcode)) {
            return null;
        }

        if (isset($langcode)) {
            $selected = $langcode;
        } else {
            $selected = $this->menu($languages, 'en', $this->text('Language (enter a number)'));
        }

        if (empty($languages[$selected])) {
            $this->error($this->text('Invalid language'));
            $this->selectLanguage();
        } else {
            $this->langcode = (string) $selected;
            $this->translation->set($this->langcode, null);
            $this->config->set('cli_langcode', $this->langcode);
        }

        return $this->langcode;
    }
127353
public static function PurseIniNameList (array $ini_name_list) {
		$ret = [];
		foreach ($ini_name_list as $ini_name) {
			$ret = array_merge_recursive($ret, static::PurseIniName($ini_name));
		}
		return $ret;
	}
33577
public Collection<String> getCurrencyCodes() {
        Collection<String> result = get(KEY_QUERY_CURRENCY_CODES, Collection.class);
        if (result == null) {
            return Collections.emptySet();
        }
        return result;
    }
1330363
public function getLanguageByString(
        $code,
        $format = 'iso639_2t',
        $default = null
    ) {
        if (empty($code)) {
            return $default;
        }

        if (!in_array($format, $this->validFormats)) {
            throw new LanguageNotFoundException('Language Format not valid.');
        }

        try {
            $result = $this->findOneBy([$format => $code]);
        } catch (NoResultException $e) {
            $result = $default;
        }

        return $result;
    }
1120139
def get_all_languages(self, sort='code'):
    
    langs = list(self.culturecode_set.all().as_languages())
    langs.extend(self.language_set.exclude(iso_639_1__in=[x.iso_639_1 for x in langs]))
    if sort in ['name_en', 'name_native']:
        langs.sort(key=lambda x: getattr(x, sort))
    elif sort == 'code':
        codes = self.languages.split(',')

        def code_sort(x):
            return codes.index(x.sort_code)

        langs.sort(key=code_sort)
    else:
        raise ValueError(
            'Invalid code option %s.  Valid options are: code, name_en, name_native' % sort)
    return langs
831232
public function locale($code, $locale = null)
    {
        $name = Intl::getLocaleBundle()->getLocaleName($code, $locale ?: $this->localeDetector->getLocale());

        return $name ? $this->fixCharset($name) : '';
    }
272377
public static function getHierarchySiblings($code)
    {
        if ($code === '') {
            return [];
        }

        $parent = static::getHierarchyParent($code);
        $hierarchyField = static::getHierarchyField();
        return static::query()->whereStartsWith($hierarchyField, $parent, strlen($code))->values($hierarchyField);
    }