Get information on the field translations

@return array of fields sourceName => targetName
@throws \MUtil_Model_ModelException
356323
public function getFieldsTranslations()
    {
        $this->_targetModel->set('completion_date', 'label', $this->_('Completion date'),
                'order', 9,
                'type', \MUtil_Model::TYPE_DATETIME
                );

        $fieldList = array('completion_date' => 'completion_date');

        foreach ($this->_targetModel->getCol('survey_question') as $name => $use) {
            if ($use) {
                $fieldList[$name] = $name;
            }
        }

        return $fieldList;
    }
982589
def _get_translated_field_names(model_instance):
        
        hvad_internal_fields = ['id', 'language_code', 'master', 'master_id', 'master_id']
        translated_field_names = set(model_instance._translated_field_names) - set(hvad_internal_fields)
        return translated_field_names
454655
public function getDataTableTranslationsAction()
    {
        // Get the current language
        $container = new Container('meliscms');
        $locale = $container['melis-lang-locale'];
    
        $translator = $this->getServiceLocator()->get('translator');
    
        $transData = array(
            'sEmptyTable' => $translator->translate('tr_meliscms_dt_sEmptyTable'),
            'sInfo' => $translator->translate('tr_meliscms_dt_sInfo'),
            'sInfoEmpty' => $translator->translate('tr_meliscms_dt_sInfoEmpty'),
            'sInfoFiltered' => $translator->translate('tr_meliscms_dt_sInfoFiltered'),
            'sInfoPostFix' => $translator->translate('tr_meliscms_dt_sInfoPostFix'),
            'sInfoThousands' => $translator->translate('tr_meliscms_dt_sInfoThousands'),
            'sLengthMenu' => $translator->translate('tr_meliscms_dt_sLengthMenu'),
            'sLoadingRecords' => $translator->translate('tr_meliscms_dt_sLoadingRecords'),
            'sProcessing' => $translator->translate('tr_meliscms_dt_sProcessing'),
            'sSearch' => $translator->translate('tr_meliscms_dt_sSearch'),
            'sZeroRecords' => $translator->translate('tr_meliscms_dt_sZeroRecords'),
            'oPaginate' => array(
                'sFirst' => $translator->translate('tr_meliscms_dt_sFirst'),
                'sLast' => $translator->translate('tr_meliscms_dt_sLast'),
                'sNext' => $translator->translate('tr_meliscms_dt_sNext'),
                'sPrevious' => $translator->translate('tr_meliscms_dt_sPrevious'),
            ),
            'oAria' => array(
                'sSortAscending' => $translator->translate('tr_meliscms_dt_sSortAscending'),
                'sSortDescending' => $translator->translate('tr_meliscms_dt_sSortDescending'),
            ),
        );
    
        return new JsonModel($transData);
    }
1289530
public function getCMSFields() {
        $fields=new FieldList(
                            new TabSet('Root',
                                    new Tab('Main', _t('KapostObject.MAIN', '_Main'),
                                        new ReadonlyField('Created', $this->fieldLabel('Created')),
                                        new ReadonlyField('KapostChangeTypeNice', $this->fieldLabel('KapostChangeType')),
                                        new ReadonlyField('KapostAuthor', $this->fieldLabel('KapostAuthor')),
                                        new ReadonlyField('ToPublishNice', $this->fieldLabel('ToPublish')),
                                        new ReadonlyField('ClassNameNice', _t('KapostObject.CONTENT_TYPE', '_Content Type')),
                                        new ReadonlyField('Title', $this->fieldLabel('Title')),
                                        HtmlEditorField_Readonly::create('ContentNice', $this->fieldLabel('Content'), $this->sanitizeHTML($this->Content))
                                    )
                                )
                        );
        
        
        //Allow extensions to adjust the fields
        $this->extend('updateCMSFields', $fields);
        
        return $fields;
    }
1064024
def _get_fieldtranslations(instance, field=None, lang=None):
	

	# Basic filtering: filter translations by module, model an object_id
	_filter = {"module": instance.__module__, "model": instance.__class__.__name__, "object_id": instance.id}

	if lang:
		_filter["lang"] = lang

	# If we specify a field we get ONE translation (this field translation)
	if field:
		_filter["field"] = field
		try:
			return FieldTranslation.objects.get(**_filter)
		except FieldTranslation.DoesNotExist:
			return False

	# Otherwise, we get all translations
	return FieldTranslation.objects.filter(**_filter)
831927
public function getLanguageModels() {
        $models = array();
        $ns = $this->localNs;
        
        $extensionPath = dirname(__FILE__) . '/../../../tao';
        $localesPath = $extensionPath . '/locales';
        
        if (@is_dir($localesPath) && @is_readable($localesPath)) {
            $localeDirectories = scandir($localesPath);
            
            foreach ($localeDirectories as $localeDir) {
                $path = $localesPath . '/' . $localeDir;
                if ($localeDir[0] != '.' && @is_dir($path)){
                    // Look if the lang.rdf can be read.
                    $languageModelFile = $path . '/lang.rdf';
                    if (@file_exists($languageModelFile) && @is_readable($languageModelFile)){
                        // Add this file to the returned values.
                        if (!isset($models[$ns])){
                            $models[$ns] = array();
                        }
                        
                        $models[$ns][] = $languageModelFile;
                    }
                }
            }
        
            return $models;
        }
        else{
            throw new tao_install_utils_Exception("Cannot read 'locales' directory in extenstion 'tao'.");
        }
    }
29423
public function translate()
	{
		$arguments = func_get_args();

		// Default translation parameters.
		$translate = array(
			'context' => $this->context(),
			'lang' => $this->lang(),
			'parameters' => $this->parameters(),
			'string' => $this->string(),
		);

		// Populate `$translate` variable with function arguments and/or model state.
		foreach ($this->_translate as $i => $element)
		{
			$this->_setup_element($translate, $element, $i, $arguments);
		}
		// Now that the basic data have been set, parameters that need to have context values.
		foreach ($this->_context_params as $parameter)
		{
			$translate['parameters'][$parameter] = $translate[self::CONTEXT];
		}

		// Translate using the populated data.
		return $this->i18n()
			->translate($translate['string'], $translate['context'], $translate['parameters'], $translate['lang']);
	}
1264990
public function getAllCodeFields()
    {
        static $fields = false; // Using static so it will be refreshed once per request

        if ($fields === false) {
            $fields = array();
            $model  = $this->createTrackClass('Model\\FieldMaintenanceModel');
            $rows   = $model->load(array('gtf_field_code IS NOT NULL'), array('gtf_field_code' => SORT_ASC));

            if ($rows) {
                foreach ($rows as $row) {
                    $key = FieldsDefinition::makeKey($row['sub'], $row['gtf_id_field']);
                    $fields[$key] = $row['gtf_field_code'];
                }
            }
        }

        return $fields;
    }
1018340
public function availableLocales()
    {
        if ($this->config->has('translator.locales')) {
            return $this->config->get('translator.locales');
        }

        if ($this->config->get('translator.source') !== 'files') {
            if ($this->tableExists()) {
                $locales = $this->model->distinct()->get()->pluck('locale')->toArray();
                $this->config->set('translator.locales', $locales);
                return $locales;
            }
        }

        return $this->defaultAvailableLocales;
    }
137537
public function getExportModelSource()
    {
        if (! $this->_exportModelSource) {
            $this->_exportModelSource = $this->loader->getExportModelSource($this->exportModelSourceClass);
        }

        return $this->_exportModelSource;
    }
188840
public function getAvailableLanguages()
    {
        if (!empty($this->owner->{$this->translationsAttribute})) {
            return array_keys($this->owner->{$this->translationsAttribute});
        }
        return null;
    }
68277
public function getCodeFields()
    {
        $fieldDef = $this->getTrackEngine()->getFieldsDefinition();
        $codes    = $this->tracker->getAllCodeFields();
        $results  = array_fill_keys($codes, null);

        $this->_ensureFieldData();

        foreach ($this->_fieldData as $id => $value) {
            if (!isset($codes[$id])) {
                continue;
            }

            $fieldCode           = $codes[$id];
            $results[$fieldCode] = $value;
            $field               = $fieldDef->getFieldByCode($fieldCode);
            if (!is_null($field)) {
                $results[$fieldCode] = $field->calculateFieldInfo($value, $this->_fieldData);
            }
        }

        return $results;
    }
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());
    }
850691
public function getExportFields()
    {
        $export_fields = Config::inst()->get(
            $this->modelClass,
            self::EXPORT_FIELDS
        );

        if (isset($export_fields) && is_array($export_fields)) {
            $fields = $export_fields;
        } else {
            $fields = parent::getExportFields();
        }

        $this->extend("updateExportFields", $fields);

        return $fields;
    }
398583
public function toArray()
    {
        return [
            'field' => $this->column,
            'references' => $this->references,
            'on' => $this->on,
            'on-delete' => $this->onDelete,
            'on-update' => $this->onUpdate,
            'references-model' => $this->getReferencesModel(),
            'is-self-reference' => $this->isSelfReference(),
        ];
    }
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;
    }
776676
public function allTranslations()
    {
        $model = '\\'.get_class($this);

        // the translations
        $translations = $this->translations();

        $all_translations = new Collection();
        // the original
        if ($this->translation_of) {
            $original = $model::find($this->translation_of);
            $all_translations = $all_translations->push($original);

            // get all translations from the original
            $translationsOfOriginal = $model::where('translation_of', $original->id)->get();
            foreach($translationsOfOriginal as $translation) {
                $all_translations->push($translation);
            }
        } else {
            // prepend the translation to be first in the list of translations
            $all_translations = $translations->prepend($this);
        }

        return $all_translations;
    }