Maps the query result to instances of TranslationData.
@param array $translationData
@return array|TranslationData[]
965880
protected function mapTranslationDataResult(array $translationData): array
    {
        $result = [];
        foreach ($translationData as $data) {
            $result[] = TranslationData::createFromArray($data);
        }
        return $result;
    }
629079
public function getTranslations()
    {
        return $this->owner->hasMany($this->translationClassName, [$this->languageForeignKey => $this->_ownerPrimaryKey]);
    }
865808
public function translateToRoleIds($roles)
    {
        if (!is_array($roles)) {
            if ($roles) {
                $roles = explode(",", $roles);
            } else {
                $roles = array();
            }
        }

        $lookup = array_flip($this->_roleTranslations);

        foreach ($roles as $key => $role) {
            if (isset($lookup[$role])) {
                $roles[$key] = $lookup[$role];
            }
        }

        return $roles;
    }
490006
public function getHistory(Translation $translation)
    {
        $ordered = [];
        $histories = $this->getUnorderedHistory($translation);

        /** @var History $history */
        foreach ($histories as $history) {
            $ordered[$history->getLocale()][] = $history;
        }

        return $ordered;
    }
836777
protected function installKeysAndTranslations(array $translations)
    {
        $results = [];
        foreach ($translations as $keyName => $data) {
            $results[$keyName]['created'] = false;
            if (!$this->glossaryFacade->hasKey($keyName)) {
                $this->glossaryFacade->createKey($keyName);
                $results[$keyName]['created'] = true;
            }

            foreach ($data['translations'] as $localeName => $text) {
                $results[$keyName]['translation'][$localeName] = $this->addTranslation($localeName, $keyName, $text);
            }
        }

        return $results;
    }
303611
public function getTranslations($lang)
    {
        $path = $this->getTranslationPathBaseDirectory('lang', $lang);

        if (!is_readable($path)) {
            return array();
        }

        $data = file_get_contents($path);
        $translations = json_decode($data, true);

        return $translations;
    }
949664
private function mapTranslation(ClassMetadata $metadata)
    {
        // In the case A -> B -> TranslationInterface, B might not have mapping defined as it
        // is probably defined in A, so in that case, we just return.
        if (!isset($this->configs[$metadata->name])) {
            return;
        }

        $metadata->mapManyToOne([
            'fieldName'    => 'translatable' ,
            'targetEntity' => $this->configs[$metadata->name],
            'inversedBy'   => 'translations' ,
            'joinColumns'  => [[
                'name'                 => 'translatable_id',
                'referencedColumnName' => 'id',
                'onDelete'             => 'CASCADE',
                'nullable'             => false,
            ]],
        ]);

        if (!$metadata->hasField('locale')) {
            $metadata->mapField([
                'fieldName' => 'locale',
                'type'      => 'string',
                'nullable'  => false,
            ]);
        }

        // Map unique index.
        $columns = [
            $metadata->getSingleAssociationJoinColumnName('translatable'),
            'locale'
        ];

        if (!$this->hasUniqueConstraint($metadata, $columns)) {
            $constraints = isset($metadata->table['uniqueConstraints']) ? $metadata->table['uniqueConstraints'] : [];

            $constraints[$metadata->getTableName().'_uniq_trans'] = [
                'columns' => $columns,
            ];

            $metadata->setPrimaryTable([
                'uniqueConstraints' => $constraints,
            ]);
        }
    }
1359001
private function translate(array $translations)
    {
        foreach ($translations as $key => $part) {
            if (is_array($part)) {
                $translations[$key] = $this->translate($part);
            } else {
                $translations[$key] = $this->translateText($part);
            }
        }

        return $translations;
    }
32618
private function mapDataToFactObjects(array $data)
    {
        return array_map(function($factData) {
            return (new Fact)
                ->setText($factData['text'])
                ->setGroups($factData['groups'])
            ;
        }, $data);
    }
1338844
private function prepareValues($arrayData)
    {
        $arrayData = array_values($arrayData);

        $preparedValues = [];
        $vNumber = 1;
        foreach ($arrayData as $value) {
            $preparedValues[":value{$vNumber}"] = "$value";
            $vNumber++;
        }

        unset($arrayData);
        unset($vNumber);

        return $preparedValues;
    }
1006463
private function addTranslationsToArray($array = []): array
    {
        foreach($array as $language => $groups){
            foreach($groups as $groupname => $entries){
                $group_model = TranslationGroup::where('name', $groupname)->first();
                $first_level_translations = Translation::where([
                    ['parent', '=', NULL],
                    ['translation_group', '=', $group_model->id],
                    ['language', '=', $language]
                ])->get();
                
                foreach($first_level_translations as $translation){
                    $array[$language][$groupname][$translation->key] = $this->getValue($language, $translation, $group_model);
                }

            }
        }
        return $array;
    }
232075
public function transform($translation)
    {
        $translation = $this->entityToArray(ContentTranslation::class, $translation);
        return [
            'id'             => (int) $translation['id'],
            'langCode'       => $translation['lang_code'],
            'title'          => $translation['title'],
            'teaser'         => $translation['teaser'],
            'body'           => $translation['body'],
            'seoTitle'       => $translation['seo_title'],
            'seoDescription' => $translation['seo_description'],
            'isActive'       => (bool) $translation['is_active'],
            'createdAt'      => $translation['created_at'],
            'updatedAt'      => $translation['updated_at'],
        ];
    }
834764
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;
    }
464825
public function data($lang=null) {

        if ($lang) {
            return isset($this->_languages[$lang]) ? $this->_languages[$lang] : [];
        }

        return $this->_languages;
    }
1026020
private function addTranslationGroupsToArray($array = []): array
    {
        foreach(array_keys($array) as $language){
            foreach($this->translation_groups as $group){
                $array[$language][$group->name] = [];
            }
        }
        return $array;
    }
1224468
protected function getWhereClause(array $data): array
    {
        $result = [];

        if (empty($data['criteria'])) {
            return $result;
        }

        // get current module searchable fields.
        $moduleFields = $this->filterFields(array_keys($this->searchFields));

        foreach ($data['criteria'] as $fieldName => $criterias) {
            if (empty($criterias)) {
                continue;
            }

            $fieldName = $this->table->aliasField($fieldName);
            if (!in_array($fieldName, $moduleFields)) {
                continue;
            }

            foreach ($criterias as $criteria) {
                $condition = $this->getWhereCondition($fieldName, $criteria);

                if (empty($condition)) {
                    continue;
                }
                $result[] = $condition;
            }
        }

        return $result;
    }
978870
public function transform($translation)
    {
        $translation = $this->entityToArray(FileTranslation::class, $translation);
        return [
            'id'          => (int) $translation['id'],
            'langCode'    => $translation['lang_code'],
            'title'       => $translation['title'],
            'description' => $translation['description'],
            'createdAt'   => $translation['created_at'],
            'updatedAt'   => $translation['updated_at'],
        ];
    }