public function getTranslations(LocaleEntity $locale, TranslatableEntity $translatable)
    {
        $numPlurals = $locale->getPluralCount();

        $result = [
            'current' => null,
            'others' => [],
        ];
        $translations = $this->app->make(TranslationRepository::class)->findBy(['translatable' => $translatable, 'locale' => $locale], ['createdOn' => 'DESC']);
        $dh = $this->app->make('helper/date');
        $uh = $this->app->make(UserService::class);
        foreach ($translations as $translation) {
            /* @var \CommunityTranslation\Entity\Translation $translation */
            $texts = [];
            switch (($translatable->getPlural() === '') ? 1 : $numPlurals) {
                case 6:
                    $texts[] = $translation->getText5();
                    /* @noinspection PhpMissingBreakStatementInspection */
                case 5:
                    $texts[] = $translation->getText4();
                    /* @noinspection PhpMissingBreakStatementInspection */
                case 4:
                    $texts[] = $translation->getText3();
                    /* @noinspection PhpMissingBreakStatementInspection */
                case 3:
                    $texts[] = $translation->getText2();
                    /* @noinspection PhpMissingBreakStatementInspection */
                case 2:
                    $texts[] = $translation->getText1();
                    /* @noinspection PhpMissingBreakStatementInspection */
                case 1:
                default:
                    $texts[] = $translation->getText0();
                    break;
            }
            $item = [
                'id' => $translation->getID(),
                'createdOn' => $dh->formatPrettyDateTime($translation->getCreatedOn(), false, true),
                'createdBy' => $uh->format($translation->getCreatedBy()),
                'approved' => $translation->isApproved(),
                'translations' => array_reverse($texts),
            ];
            if ($translation->isCurrent()) {
                $item['currentSince'] = $dh->formatPrettyDateTime($translation->getCurrentSince(), false, true);
                $result['current'] = $item;
            } else {
                $result['others'][] = $item;
            }
        }

        return $result;
    }
public function getTranslations(LocaleEntity $locale, TranslatableEntity $translatable)
    {
        $numPlurals = $locale->getPluralCount();

        $result = [
            'current' => null,
            'others' => [],
        ];
        $translations = $this->app->make(TranslationRepository::class)->findBy(['translatable' => $translatable, 'locale' => $locale], ['createdOn' => 'DESC']);
        $dh = $this->app->make('helper/date');
        $uh = $this->app->make(UserService::class);
        foreach ($translations as $translation) {
            /* @var \CommunityTranslation\Entity\Translation $translation */
            $texts = [];
            switch (($translatable->getPlural() === '') ? 1 : $numPlurals) {
                case 6:
                    $texts[] = $translation->getText5();
                    /* @noinspection PhpMissingBreakStatementInspection */
                case 5:
                    $texts[] = $translation->getText4();
                    /* @noinspection PhpMissingBreakStatementInspection */
                case 4:
                    $texts[] = $translation->getText3();
                    /* @noinspection PhpMissingBreakStatementInspection */
                case 3:
                    $texts[] = $translation->getText2();
                    /* @noinspection PhpMissingBreakStatementInspection */
                case 2:
                    $texts[] = $translation->getText1();
                    /* @noinspection PhpMissingBreakStatementInspection */
                case 1:
                default:
                    $texts[] = $translation->getText0();
                    break;
            }
            $item = [
                'id' => $translation->getID(),
                'createdOn' => $dh->formatPrettyDateTime($translation->getCreatedOn(), false, true),
                'createdBy' => $uh->format($translation->getCreatedBy()),
                'approved' => $translation->isApproved(),
                'translations' => array_reverse($texts),
            ];
            if ($translation->isCurrent()) {
                $item['currentSince'] = $dh->formatPrettyDateTime($translation->getCurrentSince(), false, true);
                $result['current'] = $item;
            } else {
                $result['others'][] = $item;
            }
        }

        return $result;
    }
public function getTranslations ( LocaleEntity $ locale , TranslatableEntity $ translatable ) { $ numPlurals = $ locale -> getPluralCount ( ) ; $ result = [ 'current' => null , 'others' => [ ] , ] ; $ translations = $ this -> app -> make ( TranslationRepository :: class ) -> findBy ( [ 'translatable' => $ translatable , 'locale' => $ locale ] , [ 'createdOn' => 'DESC' ] ) ; $ dh = $ this -> app -> make ( 'helper/date' ) ; $ uh = $ this -> app -> make ( UserService :: class ) ; foreach ( $ translations as $ translation ) { /* @var \CommunityTranslation\Entity\Translation $translation */ $ texts = [ ] ; switch ( ( $ translatable -> getPlural ( ) === '' ) ? 1 : $ numPlurals ) { case 6 : $ texts [ ] = $ translation -> getText5 ( ) ; /* @noinspection PhpMissingBreakStatementInspection */ case 5 : $ texts [ ] = $ translation -> getText4 ( ) ; /* @noinspection PhpMissingBreakStatementInspection */ case 4 : $ texts [ ] = $ translation -> getText3 ( ) ; /* @noinspection PhpMissingBreakStatementInspection */ case 3 : $ texts [ ] = $ translation -> getText2 ( ) ; /* @noinspection PhpMissingBreakStatementInspection */ case 2 : $ texts [ ] = $ translation -> getText1 ( ) ; /* @noinspection PhpMissingBreakStatementInspection */ case 1 : default : $ texts [ ] = $ translation -> getText0 ( ) ; break ; } $ item = [ 'id' => $ translation -> getID ( ) , 'createdOn' => $ dh -> formatPrettyDateTime ( $ translation -> getCreatedOn ( ) , false , true ) , 'createdBy' => $ uh -> format ( $ translation -> getCreatedBy ( ) ) , 'approved' => $ translation -> isApproved ( ) , 'translations' => array_reverse ( $ texts ) , ] ; if ( $ translation -> isCurrent ( ) ) { $ item [ 'currentSince' ] = $ dh -> formatPrettyDateTime ( $ translation -> getCurrentSince ( ) , false , true ) ; $ result [ 'current' ] = $ item ; } else { $ result [ 'others' ] [ ] = $ item ; } } return $ result ; }
Search all the translations associated to a translatable string.

@param LocaleEntity $locale
@param TranslatableEntity $translatable

@return array
Search all the translations associated to a translatable string .