original_string: public function translate($entity, $locale)
      {
          $metadata = $this->metadataCollection->getMetadata($entity);
          if($metadata === null) {
              return null;
          }
  
          //translation data is stored inside the object
          if($locale === $this->defaultLocale) {
              return;
          }
  
          $accessor = PropertyAccess::createPropertyAccessor();   
          if($metadata !== null) {
              foreach($metadata->getProperties() as $property) {
                  $strategy = $this->strategyResolver->getStrategy($property->getStrategy());
                  $value = $strategy->getTranslation($entity, $property, $locale, $metadata);
                  $accessor->setValue($entity, $property->getName(), $value);
              }
          }
      }
code: public function translate($entity, $locale)
      {
          $metadata = $this->metadataCollection->getMetadata($entity);
          if($metadata === null) {
              return null;
          }
  
          //translation data is stored inside the object
          if($locale === $this->defaultLocale) {
              return;
          }
  
          $accessor = PropertyAccess::createPropertyAccessor();   
          if($metadata !== null) {
              foreach($metadata->getProperties() as $property) {
                  $strategy = $this->strategyResolver->getStrategy($property->getStrategy());
                  $value = $strategy->getTranslation($entity, $property, $locale, $metadata);
                  $accessor->setValue($entity, $property->getName(), $value);
              }
          }
      }
code_tokens: public function translate ( $ entity , $ locale ) { $ metadata = $ this -> metadataCollection -> getMetadata ( $ entity ) ; if ( $ metadata === null ) { return null ; } //translation data is stored inside the object if ( $ locale === $ this -> defaultLocale ) { return ; } $ accessor = PropertyAccess :: createPropertyAccessor ( ) ; if ( $ metadata !== null ) { foreach ( $ metadata -> getProperties ( ) as $ property ) { $ strategy = $ this -> strategyResolver -> getStrategy ( $ property -> getStrategy ( ) ) ; $ value = $ strategy -> getTranslation ( $ entity , $ property , $ locale , $ metadata ) ; $ accessor -> setValue ( $ entity , $ property -> getName ( ) , $ value ) ; } } }
docstring: Translate an entity. All stored translation data will be applied to this object. It should be called only inside the
  doctrine postLoad hook, because it doesn't handle recursive connections.
  
  @param $entity
  @param $locale
  @return null
  @throws \Exception
docstring_tokens: Translate an entity . All stored translation data will be applied to this object . It should be called only inside the doctrine postLoad hook because it doesn t handle recursive connections .