original_string: public function findTranslations(Query $query, array $options)
      {
          $locales = isset($options['locales']) ? $options['locales'] : [];
          $targetAlias = $this->_translationTable->getAlias();
  
          return $query
              ->contain([$targetAlias => function ($query) use ($locales, $targetAlias) {
                  if ($locales) {
                      /* @var \Cake\Datasource\QueryInterface $query */
                      $query->where(["$targetAlias.locale IN" => $locales]);
                  }
  
                  return $query;
              }])
              ->formatResults([$this, 'groupTranslations'], $query::PREPEND);
      }
code: public function findTranslations(Query $query, array $options)
      {
          $locales = isset($options['locales']) ? $options['locales'] : [];
          $targetAlias = $this->_translationTable->getAlias();
  
          return $query
              ->contain([$targetAlias => function ($query) use ($locales, $targetAlias) {
                  if ($locales) {
                      /* @var \Cake\Datasource\QueryInterface $query */
                      $query->where(["$targetAlias.locale IN" => $locales]);
                  }
  
                  return $query;
              }])
              ->formatResults([$this, 'groupTranslations'], $query::PREPEND);
      }
code_tokens: public function findTranslations ( Query $ query , array $ options ) { $ locales = isset ( $ options [ 'locales' ] ) ? $ options [ 'locales' ] : [ ] ; $ targetAlias = $ this -> _translationTable -> getAlias ( ) ; return $ query -> contain ( [ $ targetAlias => function ( $ query ) use ( $ locales , $ targetAlias ) { if ( $ locales ) { /* @var \Cake\Datasource\QueryInterface $query */ $ query -> where ( [ "$targetAlias.locale IN" => $ locales ] ) ; } return $ query ; } ] ) -> formatResults ( [ $ this , 'groupTranslations' ] , $ query :: PREPEND ) ; }
docstring: Custom finder method used to retrieve all translations for the found records.
  Fetched translations can be filtered by locale by passing the `locales` key
  in the options array.
  
  Translated values will be found for each entity under the property `_translations`,
  containing an array indexed by locale name.
  
  ### Example:
  
  ```
  $article = $articles->find('translations', ['locales' => ['eng', 'deu'])->first();
  $englishTranslatedFields = $article->get('_translations')['eng'];
  ```
  
  If the `locales` array is not passed, it will bring all translations found
  for each record.
  
  @param \Cake\ORM\Query $query The original query to modify
  @param array $options Options
  @return \Cake\ORM\Query
docstring_tokens: Custom finder method used to retrieve all translations for the found records . Fetched translations can be filtered by locale by passing the locales key in the options array .