public function translate($object, $locale)
    {
        $classStack = $this->getNamespacesFromClass(get_class($object));

        foreach ($classStack as $classNamespace) {
            if (!array_key_exists($classNamespace, $this->configuration)) {
                continue;
            }

            $configuration = $this->configuration[$classNamespace];
            $idGetter = $configuration['idGetter'];
            $entityId = $object->$idGetter();

            foreach ($configuration['fields'] as $fieldName => $fieldConfiguration) {
                $setter = $fieldConfiguration['setter'];
                $translation = $this
                    ->entityTranslationProvider
                    ->getTranslation(
                        $configuration['alias'],
                        $entityId,
                        $fieldName,
                        $locale
                    );

                if ($translation || !$this->fallback) {
                    $object->$setter($translation);
                }
            }
        }

        return $object;
    }
public function translate($object, $locale)
    {
        $classStack = $this->getNamespacesFromClass(get_class($object));

        foreach ($classStack as $classNamespace) {
            if (!array_key_exists($classNamespace, $this->configuration)) {
                continue;
            }

            $configuration = $this->configuration[$classNamespace];
            $idGetter = $configuration['idGetter'];
            $entityId = $object->$idGetter();

            foreach ($configuration['fields'] as $fieldName => $fieldConfiguration) {
                $setter = $fieldConfiguration['setter'];
                $translation = $this
                    ->entityTranslationProvider
                    ->getTranslation(
                        $configuration['alias'],
                        $entityId,
                        $fieldName,
                        $locale
                    );

                if ($translation || !$this->fallback) {
                    $object->$setter($translation);
                }
            }
        }

        return $object;
    }
public function translate ( $ object , $ locale ) { $ classStack = $ this -> getNamespacesFromClass ( get_class ( $ object ) ) ; foreach ( $ classStack as $ classNamespace ) { if ( ! array_key_exists ( $ classNamespace , $ this -> configuration ) ) { continue ; } $ configuration = $ this -> configuration [ $ classNamespace ] ; $ idGetter = $ configuration [ 'idGetter' ] ; $ entityId = $ object -> $ idGetter ( ) ; foreach ( $ configuration [ 'fields' ] as $ fieldName => $ fieldConfiguration ) { $ setter = $ fieldConfiguration [ 'setter' ] ; $ translation = $ this -> entityTranslationProvider -> getTranslation ( $ configuration [ 'alias' ] , $ entityId , $ fieldName , $ locale ) ; if ( $ translation || ! $ this -> fallback ) { $ object -> $ setter ( $ translation ) ; } } } return $ object ; }
Translate object.

@param object $object Object
@param string $locale Locale to be translated

@return object Translated Object
Translate object .