Handle form post

@param  string                   $locale The locale to assign to it
@return Illuminate\Http\Response
493006
public function store($locale = null)
    {
        // Get the default locale
        if (!$locale) {
            $locale = Decoy::defaultLocale();
        }

        // Hydrate the elements collection
        $elements = app('decoy.elements')
            ->localize($locale)
            ->hydrate(true);

        // If the user has customized permissions, filter the elements to only the
        // allowed pages of elements.
        if ($permissions = app('decoy.user')->getPermissionsAttribute()) {
            $elements->onlyPages($permissions->elements);
        }

        // Get all the input such that empty file fields are removed from the input.
        $input = Decoy::filteredInput();

        // Validate the input
        $validator = Validator::make($input, $elements->rules());
        if ($validator->fails()) {
            throw new ValidationFail($validator);
        }

        // Merge the input into the elements and save them.  Key must be converted back
        // from the | delimited format necessitated by PHP
        $elements->asModels()->each(function (Element $el) use ($elements, $input) {

            // Inform the model as to whether the model already exists in the db.
            if ($el->exists = $elements->keyUpdated($el->key)) {
                $el->syncOriginal();
            }

            // Handle images differently, since they get saved in the Images table
            if ($el->type == 'image') {
                return $this->storeImage($el, $input);
            }

            // Empty file fields will have no key as a result of the above filtering
            $key = $el->inputName();
            if (!array_key_exists($key, $input)) {

                // If no new video was uploaded but the preset was changed, re-encode
                if ($el->type == 'video-encoder' && $el->hasDirtyPreset('value')) {
                    $el->encode('value', $el->encodingPresetInputVal('value'));
                }

                return;
            }
            $value = $input[$key];

            // If value is an array, like it would be for the "checkboxes" type, make
            // it a comma delimited string
            if (is_array($value)) {
                $value = implode(',', $value);
            }

            // We're removing the carriage returns because YAML won't include them and
            // all multiline YAML config values were incorrectly being returned as
            // dirty.
            $value = str_replace("\r", '', $value);

            // Check if the model is dirty, manually.  Laravel's performInsert()
            // doesn't do this, thus we must check ourselves.
            if ($value == $el->value) {
                return;
            }

            // If type is a video encoder and the value is empty, delete the row to
            // force the encoding row to also delete.  This is possible because
            // videos cannot have a YAML set default value.
            if (!$value && $el->type == 'video-encoder') {
                return $el->delete();
            }

            // Save it
            $el->value = Request::hasFile($key) ?
                app('upchuck.storage')->moveUpload(Request::file($key)) :
                $value;
            $el->save();
        });

        // Clear the cache
        $elements->clearCache();

        // Redirect back to index
        return Redirect::to(URL::current())->with('success',
            __('decoy::elements.successfully_saved'));
    }
525496
public function setLocale($locale)
	{
		$this['config']->set('app.locale', $locale);

		$this['translator']->setLocale($locale);

		$this['events']->fire('locale.changed', array($locale));
	}
153913
public function translate($locale = null) {
        $locale = isset($locale) ? $locale : Locale\get_active_locale();

        if( in_array( $locale, Locale\get_locales() ) )
            throw new TranslatableException(
                _('Invalid locale')
            );

        $language = $this->getByLocale($locale);

        return $this->translations()
            ->where('language_id', $language->id)
            ->first();
    }
887394
public function setLocale($locale)
    {
        // Handle from locale + country
        switch (strtolower($locale)) {
            // “…”
            case 'pt-br':
                $this->opening = Fixer::LDQUO;
                $this->openingSuffix = '';
                $this->closing = Fixer::RDQUO;
                $this->closingPrefix = '';

                return;
        }

        // Handle from locale only
        $short = Fixer::getLanguageFromLocale($locale);

        switch ($short) {
            // « … »
            case 'fr':
                $this->opening = Fixer::LAQUO;
                $this->openingSuffix = Fixer::NO_BREAK_SPACE;
                $this->closing = Fixer::RAQUO;
                $this->closingPrefix = Fixer::NO_BREAK_SPACE;
                break;
            // «…»
            case 'hy':
            case 'az':
            case 'hz':
            case 'eu':
            case 'be':
            case 'ca':
            case 'el':
            case 'it':
            case 'no':
            case 'fa':
            case 'lv':
            case 'pt':
            case 'ru':
            case 'es':
            case 'uk':
                $this->opening = Fixer::LAQUO;
                $this->openingSuffix = '';
                $this->closing = Fixer::RAQUO;
                $this->closingPrefix = '';
                break;
            // „…“
            case 'de':
            case 'ka':
            case 'cs':
            case 'et':
            case 'is':
            case 'lt':
            case 'mk':
            case 'ro':
            case 'sk':
            case 'sl':
            case 'wen':
                $this->opening = Fixer::BDQUO;
                $this->openingSuffix = '';
                $this->closing = Fixer::LDQUO;
                $this->closingPrefix = '';
                break;
            // “…”
            case 'en':
            case 'us':
            case 'gb':
            case 'af':
            case 'ar':
            case 'eo':
            case 'id':
            case 'ga':
            case 'ko':
            case 'br':
            case 'th':
            case 'tr':
            case 'vi':
                $this->opening = Fixer::LDQUO;
                $this->openingSuffix = '';
                $this->closing = Fixer::RDQUO;
                $this->closingPrefix = '';
                break;
            // ”…”
            case 'fi':
            case 'sv':
            case 'bs':
                $this->opening = Fixer::RDQUO;
                $this->openingSuffix = '';
                $this->closing = Fixer::RDQUO;
                $this->closingPrefix = '';
                break;
        }
    }
550949
protected function filterLocale(Locale $locale)
    {
        $language = substr($locale->locale, 0, 2);

        $this->addLocale($locale->locale);
        $this->addLocale($language);
    }
1156606
public function load($locale)
    {
        if ($this->isLoaded($locale)) {
            return;
        }
        $this->languages[$locale] = $this->handler->load($locale);
    }
230089
public function setLocale($locale)
    {
        $this->locale = $locale;

        $this->getContentRoute()->setLocale($locale);

        return $this;
    }
633805
public function translate($locale) {
		$localeEntity = clone $this;
		$localeEntity->setLocale($locale);
		if(isset($this->data['translations'][$locale]))
			$localeEntity->_set($this->data['translations'][$locale]);
		unset($localeEntity->data['translations'][$locale]);
		$localeEntity->data['translations'][$this->getLocale()] = $this->data['properties'];

		return $localeEntity;
	}
1193885
public function setLocale(string $locale): self
	{
		if ($locale === '') {
			$this->locale = $locale;
		} else {
			if (!\Locale::parseLocale($locale)) {
				throw new \InvalidArgumentException(sprintf('Invalid locale "%s"', $locale));
			}
			$this->locale = \Locale::canonicalize($locale);
		}

		$this->setOptions['locale'] = null;

		return $this;
	}
569527
public function setLocale($locale = null)
    {
        $locale = self::_prepareLocale($locale);

        if (isset(self::$_localeData[(string) $locale]) === false) {
            $region = substr((string) $locale, 0, 3);
            if (isset($region[2]) === true) {
                if (($region[2] === '_') or ($region[2] === '-')) {
                    $region = substr($region, 0, 2);
                }
            }

            if (isset(self::$_localeData[(string) $region]) === true) {
                $this->_locale = $region;
            } else {
                $this->_locale = 'root';
            }
        } else {
            $this->_locale = $locale;
        }
    }
703029
public function saveTranslations(Locale $locale, array $postedTranslations)
    {
        $editedTranslations = $this->postedValuesToTranslation($locale, $postedTranslations);
        $editedTranslations->toPoFile($locale->getPoFilePath(WP_ENV));

        return $this->generateTranslationFiles($locale);
    }
187759
public function findByLocale($locale)
    {
        // Get sanitized locale
        $locale = Locale::sanitizeLocale($locale);

        return isset($this->available[$locale]) ? $this->available[$locale] : null;
    }
396330
public function getLocalization($locale)
	{
		$localization = parent::getLocalization($locale);
		
		// Create fake localization if not persisted
		if (is_null($localization)) {
			$localization = $this->createLocalization($locale);
		}
		
		return $localization;
	}
663103
public function getNewTranslation($locale)
    {
        $modelName = $this->getTranslationModelName();
        $translation = new $modelName();
        $translation->setAttribute($this->getLocaleKey(), $locale);
        $this->translations->add($translation);

        return $translation;
    }
791842
public function setLocale($locale = null)
    {
        if (is_null($locale)) {
            $locale = $this->getParent()->getLocale();
        }
        $this->locale = $locale;

        return $this;
    }
369208
public function switchLocale($locale)
    {
        if (in_array($locale, $this->config['locales'])) {
            app('session')->put('administrator_locale', $locale);
        }

        return redirect()->back();
    }
718288
public function setLocale($locale)
    {
        $this->parentSetLocale($locale);
        $this->formatCache = [];
        $this->dateFormatCache = [];
        return $this;
    }