Save all translated fields.
486124
def save_translated_fields(self):
        
        fields = {}

        # Collect all translated fields {'name': 'value'}
        for field in self._translated_fields:
            try:
                value = self.cleaned_data[field]
            except KeyError:  # Field has a ValidationError
                continue
            fields[field] = value

        # Set the field values on their relevant models
        translations = self.instance._set_translated_fields(**fields)

        # Perform full clean on models
        non_translated_fields = set(('id', 'master_id', 'language_code'))
        for translation in translations:
            self._post_clean_translation(translation)

            # Assign translated fields to the model (using the TranslatedAttribute descriptor)
            for field in translation._get_field_names():
                if field in non_translated_fields:
                    continue
                setattr(self.instance, field, getattr(translation, field))
104121
protected function saveMetas()
    {
        $metas = '<?php return '.var_export($this->metas->getAll(), true).';';
        file_put_contents($this->getMetaFile(), $metas);
    }
1098907
def fields_need_translation(self, elem, destination_lang):
        

        fields = self._get_translated_field_names(elem)
        elem_langs = elem.get_available_languages()
        # if we don't have a translation for the destination lang we have to include the tuple
        if destination_lang not in elem_langs:
            return fields

        # we have the translation, we decide which fields we need to translate. we have to get the translation first
        translation = get_translation(elem, destination_lang)
        result = []
        for field in fields:
            value = getattr(translation, field, '')
            if not value or value.strip() == '':
                result.append(field)

        return result
605335
function Translations (params, translations) {

  /** @type {Object} Store current translations source */
  this._translations = {};
  /** @type {Object} Store current stats for latest merge request */
  this._stats = {};
  /** @type {Object} Set default parameters */
  this.params = _.defaults(params, {
    "tree": false,
    "safeMode": false,
    "nullEmpty": false
  });
  // Set translations if given as parameter
  this.setTranslations(translations);
  // Initialize statistics
  this.initStats();

}
803356
public function saveLanguage()
    {
        if (DbHelper::isInstalled()) {
            $this->checkTokenInUrl();
        }
        $language = $this->getParam('language');
        LanguagesManager::setLanguageForSession($language);
        Url::redirectToReferrer();
    }
784830
public function save()
    {
        $keys = array_keys($this->langstrings);
        sort($keys);

        $maxlen       = 0;
        $langPrefixes = array();
        foreach ($keys as $key) {
            $tokens = explode('.', $key);
            if (preg_match('/tl_layout\.[a-z]+\.css\./', $key)) {
                $tokens = array($tokens[0], $tokens[1] . '.' . $tokens[2], $tokens[3]);
            }
            $langPrefix = '$GLOBALS[\'TL_LANG\']';
            foreach ($tokens as $token) {
                $langPrefix .= '[\'' . $token . '\']';
            }

            $langPrefixes[$key] = $langPrefix;

            if (strlen($langPrefix) > $maxlen) {
                $maxlen = strlen($langPrefix);
            }
        }

        $buffer = $this->getHead() . PHP_EOL . PHP_EOL;
        foreach ($keys as $key) {
            $prefix  = $langPrefixes[$key];
            $buffer .= sprintf(
                '%s = %s;' . PHP_EOL,
                $prefix . str_repeat(' ', ($maxlen - strlen($prefix))),
                var_export($this->getValue($key), true)
            );
        }
        $buffer  .= PHP_EOL;
        $resource = fopen($this->filename, 'wb');
        fputs($resource, $buffer);

        fclose($resource);
    }
343240
protected function saveModelForTable()
    {
        $table = $this;
        $dates = [];
        $fields = $table->getFields();
        // TODO Work with the namespace again. The FQN does not work since switching to the generator.s
        $modelContent = (new ModelContent($table->getModelName()))->setTable($table->getName());

        if (array_key_exists($field = 'deleted_at', $fields)) {
            unset($fields[$field]);

            $dates[] = $field;
            $modelContent->setTraits(['\Illuminate\Database\Eloquent\SoftDeletes']);
        } // if

        if (array_key_exists($field = 'created_at', $fields)) {
            unset($fields[$field]);

            $dates[] = $field;
        } // if

        if (array_key_exists($field = 'updated_at', $fields)) {
            unset($fields[$field]);

            $dates[] = $field;
        } // if

        if ($dates) {
            $modelContent->setDates($dates);
        } // if

        unset($fields['id']);
        $modelContent->setFillable(array_diff(array_keys($fields), $table->getBlacklist()));
        $modelContent->setCasts($table->getCastedFields());

        if ($genericCalls = $table->getGenericCalls()) {
            foreach ($genericCalls as $call) {
                if ($call instanceof ForeignKey) {
                    $modelContent->addForeignKey($call);
                } // if
            } // foreach
        } // if

        if ($sources = $table->getRelationSources()) {
            foreach ($sources as $call) {
                if ($call instanceof ForeignKey) {
                    $modelContent->addForeignKey($call);
                } // if
            } // foreach
        } // if

        $modelContent->save();

        return $this;
    }
826571
public function afterSave()
    {
        foreach ($this->translationsBuffer as $translation) {
            $this->owner->link($this->translationRelationName, $translation);
        }
    }
730319
def delete_translation_values
      field_key = FieldKey.find_by_global_key(params[:i18n_key])
      field_key.visible = false

      # not convinced it makes sense to delete the associated translations
      # phrases = I18n::Backend::ActiveRecord::Translation.where(:key => params[:i18n_key])
      # phrases.destroy_all

      field_key.save!
      render json: { success: true }
    end
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;
            }
        }
    }
1037677
def export_translations(request, language):
	
	FieldTranslation.delete_orphan_translations()
	translations = FieldTranslation.objects.filter(lang=language)
	for trans in translations:
		trans.source_text = trans.source_text.replace("'","\'").replace("\"","\\\"")
		trans.translation = trans.translation.replace("'","\'").replace("\"","\\\"")
	replacements = {"translations":translations, "lang":language}
	if len(settings.ADMINS)>0:
		replacements["last_translator"] = settings.ADMINS[0][0]
		replacements["last_translator_email"] = settings.ADMINS[0][1]
	if settings.WEBSITE_NAME:
		replacements["website_name"] = settings.WEBSITE_NAME
	response = render(request=request, template_name='modeltranslation/admin/export_translations.po', dictionary=replacements, context_instance=RequestContext(request), content_type="text/x-gettext-translation")
	response['Content-Disposition'] = 'attachment; filename="{0}.po"'.format(language)
	return response
732009
def put!(translations)
      Scope.flatten(translations).each do |key, value|
        storage.write(key, value)
      end
    end
178397
def save(self):
        
        active_language = get_language()
        for (name, value) in self.cleaned_data.items():
            if name not in registry:
                name, code = name.rsplit('_modeltranslation_', 1)
            else:
                code = None
            setting_obj, created = Setting.objects.get_or_create(name=name)
            if settings.USE_MODELTRANSLATION:
                if registry[name]["translatable"]:
                    try:
                        activate(code)
                    except:
                        pass
                    finally:
                        setting_obj.value = value
                        activate(active_language)
                else:
                    # Duplicate the value of the setting for every language
                    for code in OrderedDict(settings.LANGUAGES):
                        setattr(setting_obj,
                                build_localized_fieldname('value', code),
                                value)
            else:
                setting_obj.value = value
            setting_obj.save()
1318780
def save(self, commit=True):
        
        # set the localised fields
        for localized_field in self.instance.localized_fields:
            setattr(self.instance, localized_field, self.cleaned_data[localized_field])

        return super(LocalisedForm, self).save(commit)
200838
def store_translations(locale, data, options = {})
      super
      ActiveRecord::Base.transaction do
        store_item(locale, data)
      end if store_items? && valid_locale?(locale)
    end
461665
private function SaveGlobalVariablesToJson()
    {
        $variables = array();
        
        foreach($this->symbols->headers as $header)
        {
            if(!$header->HasGlobalVariables())
                continue;
            
            foreach($header->namespaces as $namespace)
            {
                if(!$namespace->HasGlobalVariables())
                    continue;
                
                foreach($namespace->global_variables as $variable)
                {
                    if(trim($variable->description))
                    {
                        $variables[$header->name][$namespace->name]
                            [$variable->name] = [
                                "type" => $variable->original_type,
                                "description" => $variable->description
                            ]
                        ;
                    }
                    else
                    {
                        $variables[$header->name][$namespace->name]
                            [$variable->name] = [
                                "type" => $variable->original_type
                            ]
                        ;
                    }
                }
            }
        }
        
        if(count($variables) > 0)
        {
            file_put_contents(
                $this->definitions_path . "variables.json", 
                Json::Encode($variables)
            );

            unset($variables);
        }
    }
1326684
public function saveI18N()
    {
        if (empty($this->i18n_data)) return;
        $this->i18n_relation()->getQuery()->whereIn($this->getI18NCodeField(), array_keys($this->i18n_data))->delete();
        foreach ($this->i18n_data as $locale => $data) {
            $obj                             = new $this->i18n_class();
            $data[$this->i18n_primary]       = $this->id;
            $data[$this->getI18NCodeField()] = $locale;
            $obj->create($data);
        }
    }