public function getLocales() { //Set the default locale as the first one. $currentLocale = \Config::get('app.locale'); $locales = ManagerServiceProvider::getLists($this->manager->getTranslation()->groupBy('locale')->lists('locale')) ?: []; // limit the locale list to what is in the config $configShowLocales = $this->manager->config(Manager::SHOW_LOCALES_KEY, []); if ($configShowLocales) { if (!is_array($configShowLocales)) { $configShowLocales = array($configShowLocales); } $locales = array_intersect($locales, $configShowLocales); } $configLocales = $this->manager->config(Manager::ADDITIONAL_LOCALES_KEY, []); if (!is_array($configLocales)) { $configLocales = array($configLocales); } $locales = array_merge(array($currentLocale), $configLocales, $locales); return array_flatten(array_unique($locales)); }
public function getGroupList() { if ($this->groupList === null) { // read it in $groups = $this->getTranslation()->groupBy('group'); $excludedGroups = $this->config(Manager::EXCLUDE_GROUPS_KEY); if ($excludedGroups) { $groups = $groups->whereNotIn('group', $excludedGroups); } $this->groupList = ManagerServiceProvider::getLists($groups->lists('group', 'group')); } return $this->groupList; }
protected function loadLocales() { //Set the default locale as the first one. $currentLocale = \Config::get('app.locale'); $primaryLocale = $this->primaryLocale; $translatingLocale = \Cookie::get($this->cookieName(self::COOKIE_TRANS_LOCALE), $currentLocale); $locales = ManagerServiceProvider::getLists($this->getTranslation()->groupBy('locale')->lists('locale')) ?: []; // limit the locale list to what is in the config $configShowLocales = $this->manager->config(Manager::SHOW_LOCALES_KEY, []); if ($configShowLocales) { if (!is_array($configShowLocales)) { $configShowLocales = array($configShowLocales); } $locales = array_intersect($locales, $configShowLocales); } $configLocales = $this->manager->config(Manager::ADDITIONAL_LOCALES_KEY, []); if (!is_array($configLocales)) { $configLocales = array($configLocales); } $locales = array_merge(array($primaryLocale, $translatingLocale, $currentLocale), $configLocales, $locales); return array_flatten(array_unique($locales)); }