Prepare list response.

@param DoctrineListBuilder $listBuilder
@param string $locale

@return array
5093
private function prepareListResponse(DoctrineListBuilder $listBuilder, $locale)
    {
        $listResponse = $listBuilder->execute();
        $listResponse = $this->addAvatars($listResponse, $locale);

        $ids = $listBuilder->getIds();
        if (null !== $ids) {
            $comparator = $this->getComparator();
            // the @ is necessary in case of a PHP bug https://bugs.php.net/bug.php?id=50688
            @usort(
                $listResponse,
                function($a, $b) use ($comparator, $ids) {
                    return $comparator->compare($a['id'], $b['id'], $ids);
                }
            );
        }

        return $listResponse;
    }
302760
protected function prepareListLanguage(array &$list)
    {
        foreach ($list as $id => &$item) {
            $item['file_exists'] = is_file($this->translation->getFile($id));
        }
    }
246192
public function load($locale, $group, $namespace = null)
    {
        $query = \DB::table('translations')
            ->where('locale', $locale)
            ->where('group', $group);

        return ServiceProvider::pluckOrLists($query, 'value', 'name');
    }
176221
protected function initCatalogs($locale, $domain) {
		if (empty($this->resources)) {
			throw new NoResources('Resources hasn\'t been provided');
		}
		
		// Add the preinit data to the request if need
		if ($this->preinitNeed) {
			list($locale, $domain) = $this->handlePreinit($locale, $domain);
		}
		
		// Mark as initialized anyway
		$this->markAsInitialized($locale, $domain);
		
		// Try from cache
		if ($this->cache !== null) {
			$catalogsCached = $this->cache->getCatalogs($locale, $domain);
			
			if ($catalogsCached !== null) {
				$this->catalogs = array_replace_recursive($this->catalogs, $catalogsCached);
				
				// Request to the resources is still need ?
				$requestDiff = $this->calculateRequestDiff($locale, $domain, $catalogsCached);
				
				if ($requestDiff === null) {
					return;
				}
				
				list($locale, $domain) = $requestDiff;
			}
		}
		
		// Try from resources
		$catalogs = $this->getCatalogsFromResources($locale, $domain);
		
		if (! empty($catalogs)) {
			$this->catalogs = array_replace_recursive($this->catalogs, $catalogs);
			
			// Store in the cache just obtained data
			if ($this->cache !== null) {
				$this->cache->setCatalogs($catalogs);
			}
		}
	}
1076380
protected function getTranslatedQuery(QueryBuilder $qb, $locale = null)
    {
        $query = $this->setTranslationHints($qb->getQuery(), $locale);

        return $query;
    }
1257251
protected function getDatabaseTranslations(LocaleInterface $locale)
    {
        $messages   = [];
        $collection = $this->repository->matching(new Criteria());
        
        $collection->map(function (DictionaryInterface $dictionary) use ($locale, &$messages) {
            $messages[$dictionary->getIdentifier()] = $dictionary->translate($locale->getCode())->getValue();
        });
        
        return $messages;
    }
365748
public function retrieveAllAsArray($locale)
    {
        $result = [];

        /** @var CustomerType $customerType */
        foreach ($this->retrieveAll($locale) as $customerType) {
            $result[] = [
                'id' => $customerType->getId(),
                'name' => $customerType->getName(),
            ];
        }

        return $result;
    }
471036
private function executeListBuilder(array $fieldDescriptors, Request $request, ListBuilderInterface $listBuilder)
    {
        if (null === ($idsParameter = $request->get('ids'))) {
            return $listBuilder->execute();
        }

        $ids = array_filter(explode(',', $request->get('ids')));
        $listBuilder->in($fieldDescriptors['id'], $ids);

        $sorted = [];
        foreach ($listBuilder->execute() as $item) {
            $sorted[array_search($item['id'], $ids)] = $item;
        }

        ksort($sorted);

        return array_values($sorted);
    }
389845
public function getFieldDescriptors($locale)
    {
        if ($locale !== $this->currentLocale) {
            $this->initializeFieldDescriptors($locale);
        }

        return $this->fieldDescriptors;
    }
633839
public function getCatalogs($locale = null, $domain = null) {
		if ($locale === null && $domain === null) {
			return $this->catalogs;
		}
		
		if (is_string($locale)) {
			return $this->getSingleCatalog($locale, $domain);
		}
		
		if (is_array($locale)) {
			return $this->getManyCatalogs($locale, $domain);
		}
		
		throw new InvalidParameter('Locale must be a string or an array');
	}
1160191
public function getCatalogs($locale = null, $domain = null) {
		$cache   = $this->getCacheFrontend();
		$cacheId = $this->prepareCacheId($locale, $domain);
		
		// Many
		if (is_array($cacheId)) {
			$catalogsRaw = $cache->getMany($cacheId);
			
			if (empty($catalogsRaw)) {
				return;
			}
			
			$catalogs = [];
			
			foreach ($catalogsRaw as $catalogId => $catalog) {
				list($localePart, $domainPart) = explode('_', $catalogId);
				
				if (! isset($catalogs[$localePart])) {
					$catalogs[$localePart] = [];
				}
				
				$catalogs[$localePart][$domainPart] = $catalog;
			}
			
			return $catalogs;
		}
		
		// One
		$catalog = $cache->get($cacheId);
				
		if ($catalog === null) {
			return;
		}

		return [
			$locale => [
				$domain => $catalog
			]
		];
	}
6768
public function all($locale = null){

        if(!$locale){
            $locale = $this->getLocale();
        }

        $this->load($locale);

        $translations = collect([]);
        foreach($this->languages[$locale] as $key => $arg){
            $translations->put($key, $arg['value']);
        }

        return $translations;
    }
91666
private static function _calendarDetail($locale, $list)
    {
        $ret = "001";
        foreach ($list as $key => $value) {
            if (strpos($locale, '_') !== false) {
                $locale = substr($locale, strpos($locale, '_') + 1);
            }
            if (strpos($key, $locale) !== false) {
                $ret = $key;
                break;
            }
        }
        return $ret;
    }
797950
public function getLocalization($locale)
    {
        $dataCollection = $this->getLocalizations();
        $data = $dataCollection->get($locale);

        return $data;
    }
932345
public static function getListForLocale($locale)
    {
        $translation_list_en = array();
        $translation_list_locale = array();
        $result = array();

        $translation_list = TranslationQuery::create()->joinWithI18n('en')->find();

        foreach ($translation_list as $translation_item) {
            /** @var Translation $translation_item */
            $translation_list_en[$translation_item->getId()]['alias'] = $translation_item->getAlias();
            $translation_list_en[$translation_item->getId()]['title'] = $translation_item->getTitle();
        }

        $translation_list = TranslationQuery::create()->joinWithI18n($locale)->find();
        foreach ($translation_list as $translation_item) {
            /** @var Translation $translation_item */
            $translation_list_locale[$translation_item->getId()] = $translation_item->getTitle();
        }

        foreach ($translation_list_en as $id => $translation_item) {
            $result[$translation_item['alias']] = isset($translation_list_locale[$id]) && $translation_list_locale[$id] ?
                $translation_list_locale[$id] :
                ($translation_item['title'] ? $translation_item['title'] : $translation_item['alias']);
        }

        return $result;
    }
288874
public function getCatalogs($locale = null, $domain = null) {
		$cache = $this->getCacheFrontend();
		
		if (is_array($domain)) {
			$catalogs = $cache->getMany($domain);
			
			if (empty($catalogs)) {
				return;
			}
			
			return call_user_func_array('array_replace_recursive', $catalogs);
		}
		
		return $cache->get($domain);
	}
1160618
private function resolveQueryBuilder(
        QueryBuilder $queryBuilder,
        $locale,
        $locales,
        MappingInterface $mapping,
        UserInterface $user = null
    ) {
        return array_values(
            array_filter(
                array_map(
                    function(Row $row) use ($mapping, $locale, $locales, $user) {
                        return $this->resolveContent($row, $locale, $locales, $mapping, $user);
                    },
                    iterator_to_array($queryBuilder->execute())
                )
            )
        );
    }