public function getAvailableLocales()
{
if ($this->_availableLocales === 'backpack') {
- return $this->getAvailableLocalesTranslations();
+ $res = $this->getAvailableLocalesTranslations();
} else if (is_array($this->_availableLocales)) {
- return $this->_availableLocales;
+ $res = $this->_availableLocales;
}
+
+ uksort($res, [$this, '_sortLocales']);
+ return $res;
+ }
+
+ protected function _sortLocales($a, $b)
+ {
+ return strcmp($a, $b);
}
}
{
return base_path() . '/resources/lang/' . $locale . '.json';
}
+
+ protected function _sortLocales($a, $b)
+ {
+ $ea = file_exists($this->_getLanguageFile($a)) ? 1 : 0;
+ $eb = file_exists($this->_getLanguageFile($b)) ? 1 : 0;
+ if ($ea !== $eb) {
+ return $eb - $ea;
+ }
+ $sa = mb_strlen($a);
+ $sb = mb_strlen($b);
+ if ($sa !== $sb) {
+ return $sa - $sb;
+ }
+
+ return parent::_sortLocales($a, $b);
+ }
}