public function pickUpTranslation(
        Project $project,
        array $languages,
        array $domains,
        bool $revision
    ) : ? Translation {
        $repositories = $project
            ->getRepositories(
                $domains,
                $languages
            );

        $translations = array_reduce(
            $repositories,
            function (Repository $repository) use ($revision) {
                $translations = $repository->getTranslations();

                return array_filter(
                    $translations,
                    function (Translation $translation) use ($revision) {
                        return $revision === ($translation->getValue() == '');
                    }
                );
            }
        );

        $position = array_rand($translations);

        return $translations[$position];
    }
public function pickUpTranslation(
        Project $project,
        array $languages,
        array $domains,
        bool $revision
    ) : ? Translation {
        $repositories = $project
            ->getRepositories(
                $domains,
                $languages
            );

        $translations = array_reduce(
            $repositories,
            function (Repository $repository) use ($revision) {
                $translations = $repository->getTranslations();

                return array_filter(
                    $translations,
                    function (Translation $translation) use ($revision) {
                        return $revision === ($translation->getValue() == '');
                    }
                );
            }
        );

        $position = array_rand($translations);

        return $translations[$position];
    }
public function pickUpTranslation ( Project $ project , array $ languages , array $ domains , bool $ revision ) : ? Translation { $ repositories = $ project -> getRepositories ( $ domains , $ languages ) ; $ translations = array_reduce ( $ repositories , function ( Repository $ repository ) use ( $ revision ) { $ translations = $ repository -> getTranslations ( ) ; return array_filter ( $ translations , function ( Translation $ translation ) use ( $ revision ) { return $ revision === ( $ translation -> getValue ( ) == '' ) ; } ) ; } ) ; $ position = array_rand ( $ translations ) ; return $ translations [ $ position ] ; }
Given a Project, a set of languages and a set of domains, return a random
non filled yet Translation object.

If the flag revision is enabled, then only already translated elements
will be picked up

Return translation found or null if none translation is available

@param Project $project   Project
@param array   $languages Languages
@param array   $domains   Domains
@param bool    $revision  Revision only

@return Translation|null
Given a Project a set of languages and a set of domains return a random non filled yet Translation object .