Returns some trans units with their translations.

@param array $locales
@param int   $rows
@param int   $page
@param array $filters
@return array
761069
public function getTransUnitList(array $locales = null, $rows = 20, $page = 1, array $filters = null)
    {
        $sortColumn = isset($filters['sidx']) ? $filters['sidx'] : 'id';
        $order = isset($filters['sord']) ? $filters['sord'] : 'ASC';

        $builder = $this->createQueryBuilder()
            ->hydrate(false)
            ->select('id');

        $this->addTransUnitFilters($builder, $filters);
        $this->addTranslationFilter($builder, $locales, $filters);

        $results = $builder->sort($sortColumn, $order)
            ->skip($rows * ($page - 1))
            ->limit($rows)
            ->getQuery()
            ->execute();

        $ids = array();
        foreach ($results as $result) {
            $ids[] = $result['_id'];
        }

        $transUnits = array();

        if (count($ids) < 1) {
            return $transUnits;
        }

        $results = $this->createQueryBuilder()
            ->hydrate(false)
            ->field('id')->in($ids)
            ->field('translations.locale')->in($locales)
            ->sort(array($sortColumn => $order, 'translations.locale' => 'asc'))
            ->getQuery()
            ->execute();

        foreach ($results as $item) {
            $end = count($item['translations']);
            for ($i = 0; $i < $end; $i++) {
                if (!in_array($item['translations'][$i]['locale'], $locales)) {
                    unset($item['translations'][$i]);
                }
            }
            sort($item['translations']);
            $transUnits[] = $item;
        }

        return $transUnits;
    }
518327
public function errorsI18N(array $locales=[], $groups=[]) {
		if(!$locales)
			$locales = $this->getLocales();
		$data = $this->toArrayRawI18N($locales);
		$validator = $this->getValidator($locales);

		return $validator->errors($data, $groups);
	}
363739
public function loadFromArray(array $locales)
    {
        $this->items = [];

        foreach ($locales as $key => $locale) {
            $this->put($key, Locale::make($key, $locale));
        }

        return $this;
    }
270208
public function read(Collection $files, Collection $locales)
    {
        return $locales->reduce(function ($translations, $locale) use ($files) {
            $files->each(function ($file) use ($locale, &$translations) {
                if (file_exists($path = $this->pathToFile($file, $locale))) {
                    $content[$file] = include_once $path;

                    foreach (array_dot($content) as $key => $value) {
                        $translations[$key][$locale->iso6391()] = $value ? $value : '';
                    }
                }
            });

            return $translations;
        }, []);
    }
1270259
public function groupTranslations($results)
    {
        return $results->map(function ($row) {
            if (!$row instanceof EntityInterface) {
                return $row;
            }
            $translations = (array)$row->get('_i18n');
            if (empty($translations) && $row->get('_translations')) {
                return $row;
            }
            $grouped = new Collection($translations);

            $result = [];
            foreach ($grouped->combine('field', 'content', 'locale') as $locale => $keys) {
                $entityClass = $this->_table->getEntityClass();
                $translation = new $entityClass($keys + ['locale' => $locale], [
                    'markNew' => false,
                    'useSetters' => false,
                    'markClean' => true
                ]);
                $result[$locale] = $translation;
            }

            $options = ['setter' => false, 'guard' => false];
            $row->set('_translations', $result, $options);
            unset($row['_i18n']);
            $row->clean();

            return $row;
        });
    }
701887
protected function addTranslationFilter(Builder $builder, array $locales = null,  array $filters = null)
    {
        if (null !== $locales) {
            $qb = $this->createQueryBuilder()
                ->hydrate(false)
                ->distinct('id')
                ->field('translations.locale')->in($locales);

            foreach ($locales as $locale) {
                if (!empty($filters[$locale])) {
                    $builder->addAnd(
                        $builder->expr()
                            ->field('translations.content')->equals(new \MongoRegex(sprintf('/%s/i', $filters[$locale])))
                            ->field('translations.locale')->equals($locale)
                    );
                }
            }

            $ids = $qb->getQuery()->execute();
            $ids = iterator_to_array($ids);

            if (count($ids) > 0) {
                $builder->field('id')->in($ids);
            }
        }
    }
649095
public function getTranslationsByLocalesAndDomains($locales, $domains)
    {
        $em = $this->getEntityManager();
        $qb = $em->createQueryBuilder();
        $qb
            ->select('t')
            ->from('KunstmaanTranslatorBundle:Translation', 't')
            ->andWhere('t.status != :statusstring')
            ->setParameter('statusstring', Translation::STATUS_DISABLED)
            ->orderBy('t.domain', 'ASC')
            ->addOrderBy('t.keyword', 'ASC');

        if (count($locales) > 0) {
            $qb->andWhere($qb->expr()->in('t.locale', $locales));
        }

        if (count($domains) > 0) {
            $qb->andWhere($qb->expr()->in('t.domain', $domains));
        }

        $result = $qb
            ->getQuery()
            ->getResult();

        return $result;
    }
1078903
public function findAllByIdsAndLocale($locale, $ids = '')
    {
        $products = $this->productRepository->findByLocaleAndIds($locale, explode(',', $ids));

        if ($products) {
            array_walk(
                $products,
                function (&$product) use ($locale) {
                    $product = $this->productFactory->createApiEntity($product, $locale);
                }
            );
        }

        return $products;
    }
184942
private function resolveAvailableLocales(Row $row)
    {
        $locales = [];
        foreach ($row->getValues() as $key => $value) {
            if (preg_match('/^node.([a-zA-Z_]*?)Template/', $key, $matches) && '' !== $value
                && !$row->getValue(sprintf('node.%sShadow_on', $matches[1]))
            ) {
                $locales[] = $matches[1];
            }
        }

        return $locales;
    }
869636
def with_translations(*locales)
      locales = translated_locales if locales.empty?
      where :translations.matches => {:locale => {"$in" => locales.flatten}}.merge(required_fields_criteria)
    end
273104
public function extractLanguageCodesFromData(array $rows): array
    {
        $languageMask = 0;
        foreach ($rows as $row) {
            $languageMask |= $row['lang_mask'];
        }

        return $this->languageMaskGenerator->extractLanguageCodesFromMask($languageMask);
    }
792332
public static function translateKeys($records, $translations)
    {
        if (!self::iterable($records)) {
            return array();
        }
        
        $out = array();
        foreach ($records as $n => $record) {
            if (!self::iterable($record)) {
                $out[$n] = $record;
                continue;
            }
            $out[$n] = array();
            
            foreach ($record as $k => $v) {
                $new_k = (array_key_exists($k, $translations)) ? $translations[$k] : $k;
                $out[$n][$new_k] = $v;
            }
        }
        return $out;
    }
1251707
public function getRes($pageColumns = null){
      $page = array();
      $pageColumns = empty($pageColumns) && (!is_array($pageColumns)) ? $this->pageColumnsRes : $pageColumns;
      if (empty($pageColumns)) {
          $page = $this->pageArray;
      }else{
          $page = array();
          foreach ($pageColumns as $index => $key) {
              $page[$key] = $this->pageArray[$key];
          }
      }
      $lists = empty($this->lists)?array():$this->lists;
      return array(
          'lists'=>$lists,
          'page'=>$page
      );
  }
1161870
public function findForLocalesAndDomains(array $locales, array $domains)
    {
        return FileQuery::create()
            ->_if(count($locales) > 0)
                ->filterByLocale($locales, Criteria::IN)
            ->_endif()

            ->_if(count($domains) > 0)
                ->filterByDomain($domains, Criteria::IN)
            ->_endif()

            ->find($this->getConnection())
        ;
    }
1347278
public function transformRows(\Cassandra\Rows $rows)
    {
        $entries = [];

        // page through all results and transform as we go
        while (true) {
            while ($rows->valid()) {

                // transform
                $entry = $this->transform($rows->current());

                if ($entry) {
                    array_push($entries, $entry);
                }

                $rows->next();
            }

            if ($rows->isLastPage()) {
                break;
            }

            $rows = $rows->nextPage();
        }

        return $entries;
    }
1227969
public function getTranslations(
        array $domains = [],
        array $languages = [],
        callable $filter = null
    ) : array {
        $translations = array_filter(
            $this->translations,
            function (Translation $translation) {
                return $translation->getValue() != '';
            }
        );

        if (is_callable($filter)) {
            $translations = array_filter(
                $translations,
                $filter
            );
        }

        return $translations;
    }
459776
public function get($objects, $pages = null) {
		$objects = $this->getDatas ( $objects );
		return $this->format ( [ "datas" => $objects,"count" => \sizeof ( $objects ) ] );
	}