Get information on the field translations

@return array of fields sourceName => targetName
@throws \MUtil_Model_ModelException
516899
public function getFieldsTranslations()
    {
        if (! $this->_targetModel instanceof \MUtil_Model_ModelAbstract) {
            throw new \MUtil_Model_ModelTranslateException(sprintf('Called %s without a set target model.', __FUNCTION__));
        }
        $this->_targetModel->set('gto_id_token', 'label', $this->_('Token'),
                'import_descr', $this->loader->getTracker()->getTokenLibrary()->getFormat(),
                'required', true,
                'order', 2
                );

        return array('token' => 'gto_id_token') + parent::getFieldsTranslations();
    }
789799
public static function getRules()
    {
        $rules = static::rules();

        if (RevyAdmin::isTranslationMode()) {
            $object = new static();

            foreach ($rules as $field => $rule) {
                if ($object->isTranslatableField($field)) {
                    unset($rules[$field]);
                    foreach (Language::getLocales() as $locale) {
                        $rules[RevyAdmin::getTranslationFieldName($field, $locale)] = $rule;
                    }
                }
            }
        }
      
        return $rules;
    }
404531
protected function translations()
    {
        $translations = collect($this->getFiles(resource_path('lang/')))->flatMap(function ($file) {
            return [
                ($translation = $file->getBasename('.php')) => trans($translation),
            ];
        });

        return $translations->merge($this->packageTranslations());
    }
769335
protected static function get_target_locales()
    {
        // if locales are explicitly set, use these
        if (is_array(self::config()->locales)) {
            return (array)self::config()->locales;
            // otherwise check the allowed locales. If these have been set, use these
        } else if (is_array(Translatable::get_allowed_locales())) {
            return (array)Translatable::get_allowed_locales();
        }

        // last resort is to take the existing content languages
        return array_keys(Translatable::get_existing_content_languages());
    }
225002
public function getDerivedFields()
    {
        if ($this->derivedFields === null) {
            $this->derivedFields = array();

            foreach ($this->getFieldsIterator() as $name => $field) {
                if (count($field['lookup_chain']) < 2) {
                    continue;
                }

                $key = sha1($field['base'] . serialize($field['lookup_chain']));
                $fieldname = "{$field['class']}:{$field['field']}";

                if (isset($this->derivedFields[$key])) {
                    $this->derivedFields[$key]['fields'][$fieldname] = $fieldname;
                    SearchIntrospection::add_unique_by_ancestor($this->derivedFields['classes'], $field['class']);
                } else {
                    $chain = array_reverse($field['lookup_chain']);
                    array_shift($chain);

                    $this->derivedFields[$key] = array(
                        'base' => $field['base'],
                        'fields' => array($fieldname => $fieldname),
                        'classes' => array($field['class']),
                        'chain' => $chain
                    );
                }
            }
        }

        return $this->derivedFields;
    }
188840
public function getAvailableLanguages()
    {
        if (!empty($this->owner->{$this->translationsAttribute})) {
            return array_keys($this->owner->{$this->translationsAttribute});
        }
        return null;
    }
1110902
public function getLocalisedTables()
    {
        $includedTables = [];
        $baseClass = $this->owner->baseClass();
        $tableClasses = ClassInfo::ancestry($this->owner, true);
        foreach ($tableClasses as $class) {
            // Check translated fields for this class (except base table, which is always scaffolded)
            $translatedFields = $this->getLocalisedFields($class);
            if (empty($translatedFields) && $class !== $baseClass) {
                continue;
            }

            // Mark this table as translatable
            $table = DataObject::getSchema()->tableName($class);
            $includedTables[$table] = array_keys($translatedFields);
        }
        return $includedTables;
    }
477892
public function retrieve(Model $model, $source)
    {
        if ($this->isTranslated()) {
            return $model->translations->mapWithKeys(function (Model $model) {
                /** @var Taggable $model */
                return [ $model->{config('translatable.locale_key', 'locale')} => $model->tagNames() ];
            });
        }

        return $model->tagNames();
    }
1067928
public function getChangedFields() {
        if($this->isAfterSave() && method_exists($this->getEntity(), 'getUpdatedFields')) {
            if($this->getEntity()->hasSnapshotData()) {
                $actualChangedFields = $this->getEntity()->getUpdatedFields();
            } else {
                $actualChangedFields = $this->getSnapshotData();
            }
        } else { //Legacy
            $actualChangedFields = $this->getEntity()->getChangedFields();
        }
        $model = $this->getEntity();
        foreach($actualChangedFields as $index => $changedField) {
            $newValue = $model->readAttribute($changedField);
            if(is_array($newValue)) {
                $newValue = json_encode($newValue);
            }
            $oldValue = $this->getSnapshotData()[$changedField] ?? null ?? null;
            if(is_object($oldValue)) {
                $oldValue = (string)$oldValue;
            }
            if(is_object($newValue)) {
                $newValue = (string)$newValue;
            }
            if(is_bool($oldValue) || is_bool($newValue)){
                $oldValue = (bool) $oldValue;
                $newValue = (bool) $newValue;
            }
            if($oldValue === $newValue) {
                unset($actualChangedFields[$index]);
            }

        }
        return array_values($actualChangedFields);
    }
163184
private function populateTranslations()
    {
        //translations
        $aRelated = $this->owner->getRelatedRecords();
        if (isset($aRelated[$this->relation]) && $aRelated[$this->relation] != null) {
            if (is_array($aRelated[$this->relation])) {
                foreach ($aRelated[$this->relation] as $model) {
                    $this->_models[$model->getAttribute($this->languageField)] = $model;
                }
            } else {
                $model = $aRelated[$this->relation];
                $this->_models[$model->getAttribute($this->languageField)] = $model;
            }
        }
    }
451991
public function getJsTranslations()
    {
        $translations = [];
        foreach ($this->_jsTranslations as $module => $data) {
            foreach ($data as $key) {
                $translations[$key] = Yii::t($module, $key, [], Yii::$app->language);
            }
        }
        return $translations;
    }
557706
public function getFieldDefinitions()
    {
        $fieldDefinitions = array();
        foreach ($this->fieldDefinitionReferences as $reference) {
            $fieldDefinitions[] = $this->contentTypeService->loadFieldDefinition($reference);
        }

        return $fieldDefinitions;
    }
889057
public function translations()
    {
        return $this->hasMany(Translation::class, 'foreign_key', $this->getKeyName())
            ->where('table_name', $this->getTable())
            ->whereIn('locale', config('admin.multilingual.locales', []));
    }
42581
public function getRespondentAnswerTranslations()
    {
        $this->_targetModel->set($this->patientNrField, 'label', $this->_('Patient ID'),
                'order', 5,
                'required', true,
                'type', \MUtil_Model::TYPE_STRING
                );
        $this->_targetModel->set($this->orgIdField, 'label', $this->_('Organization ID'),
                'multiOptions', $this->util->getDbLookup()->getOrganizationsWithRespondents(),
                'order', 6,
                'required', true,
                'type', \MUtil_Model::TYPE_STRING
                );

        return array(
            $this->patientNrField => $this->patientNrField,
            $this->orgIdField     => $this->orgIdField,
            );
    }
276348
public function getSource()
    {
        $field = $this
            ->getForm()
            ->Fields()
            ->dataFieldByName($this->country_field);

        if (empty($field) || empty($field->Value())) {
            $locale = strtoupper(Locale::getRegion(i18n::get_locale()));
        } else {
            $locale = $field->Value();
        }

        return $this
            ->getList($locale)
            ->map("Code", "Name")
            ->toArray();
    }
224653
public function getAllTranslations()
    {
        $this->loadTranslations($this->currentLanguage);

        if (!isset($this->translations[$this->currentLanguage])) {
            return array();
        }

        return $this->translations[$this->currentLanguage];
    }
490533
public function getCMSFields() {
        $fields=new FieldList(
                            new TextField('Name', _t('SnippetLanguage.NAME', '_Name'), null, 100),
                            new TextField('FileExtension', _t('SnippetLanguage.FILE_EXTENSION', '_File Extension'), null, 45),
                            new CheckboxField('Hidden', _t('SnippetLanguage.HIDDEN', '_Hidden'))
                        );
        
        if($this->UserLanguage==false) {
            $fields->replaceField('Name', $fields->dataFieldByName('Name')->performReadonlyTransformation());
            $fields->replaceField('FileExtension', $fields->dataFieldByName('FileExtension')->performReadonlyTransformation());
        }
        
        return $fields;
    }