Creates an input element using the supplied arguments and methods.

@param string|null $currentLocale

@return mixed
504634
protected function createInput($currentLocale = null)
    {
        // Create element using arguments.
        $element = call_user_func_array([$this->form, $this->element()], array_values($this->arguments()));

        // Elements such as 'bind' do not return renderable stuff and do not accept methods.
        if ($element) {
            // Apply requested methods.
            foreach ($this->methods() as $method) {
                $methodName = $method['name'];
                $methodParameters = $method['parameters'];

                // Check if method is locale-specific.
                if (ends_with($methodName, 'ForLocale')) {
                    $methodName = strstr($methodName, 'ForLocale', true);
                    $locales = array_shift($methodParameters);
                    $locales = is_array($locales) ? $locales : [$locales];
                    if (!is_null($currentLocale) && !in_array($currentLocale, $locales)) {
                        // Method should not be applied for this locale.
                        continue;
                    }
                }

                // Call method.
                if (!empty($methodParameters)) {
                    call_user_func_array([$element, $methodName], $this->replacePlaceholdersRecursively($methodParameters, $currentLocale));
                } else {
                    $element->{$methodName}();
                }
            }
        }

        return $element;
    }
650461
public function locale($locale = null)
    {
        if ($locale) {
            $this->_locale = $locale;
        }
        if ($this->_locale) {
            return $this->_locale;
        }
        if (isset($this->_params['locale'])) {
            return $this->_params['locale'];
        }
    }
776577
public function getTranslation($locale = 'en_US', ConnectionInterface $con = null)
    {
        if (!isset($this->currentTranslations[$locale])) {
            if (null !== $this->collPersonImageI18ns) {
                foreach ($this->collPersonImageI18ns as $translation) {
                    if ($translation->getLocale() == $locale) {
                        $this->currentTranslations[$locale] = $translation;

                        return $translation;
                    }
                }
            }
            if ($this->isNew()) {
                $translation = new ChildPersonImageI18n();
                $translation->setLocale($locale);
            } else {
                $translation = ChildPersonImageI18nQuery::create()
                    ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
                    ->findOneOrCreate($con);
                $this->currentTranslations[$locale] = $translation;
            }
            $this->addPersonImageI18n($translation);
        }

        return $this->currentTranslations[$locale];
    }
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'));
    }
1043569
private function getTranslationByLocale($locale)
    {
        $attributeValueTranslation = null;

        foreach ($this->entity->getTranslations() as $translation) {
            if ($translation->getLocale() == $locale) {
                $attributeValueTranslation = $translation;
                break;
            }
        }

        return $attributeValueTranslation;
    }
626204
public function getReference($locale = null)
    {
        $locale = $locale ?: $this->getCurrentLocale();
        if (is_array($this->references) && isset($this->references[$locale])) {
            return $this->references[$locale];
        }
    }
718288
public function setLocale($locale)
    {
        $this->parentSetLocale($locale);
        $this->formatCache = [];
        $this->dateFormatCache = [];
        return $this;
    }
855229
public function currentLocale()
    {
        $langCode = $this->translator()->getLocale();
        $locales  = $this->translator()->locales();
        if (isset($locales[$langCode])) {
            $locale = $locales[$langCode];
            if (isset($locale['locale'])) {
                return $locale['locale'];
            } else {
                return $langCode;
            }
        }

        return null;
    }
566969
public static function with_locale($locale, $callback)
    {
        $oldLocale = self::$current_locale;
        static::set_locale($locale);
        try {
            return $callback();
        } finally {
            static::set_locale($oldLocale);
        }
    }
182272
public function getLocaleChain(Locale $locale)
    {
        $fallbackRule = $this->configuration->getFallbackRule();
        $localeChain = [(string)$locale => $locale];

        if ($fallbackRule['strict'] === true) {
            foreach ($fallbackRule['order'] as $localeIdentifier) {
                $localeChain[$localeIdentifier] = new Locale($localeIdentifier);
            }
        } else {
            $locale = $this->findBestMatchingLocale($locale);
            while ($locale !== null) {
                $localeChain[(string)$locale] = $locale;
                $locale = $this->getParentLocaleOf($locale);
            }
            foreach ($fallbackRule['order'] as $localeIdentifier) {
                $locale = new Locale($localeIdentifier);
                $locale = $this->findBestMatchingLocale($locale);
                while ($locale !== null) {
                    $localeChain[(string)$locale] = $locale;
                    $locale = $this->getParentLocaleOf($locale);
                }
            }
        }
        $locale = $this->configuration->getDefaultLocale();
        $localeChain[(string)$locale] = $locale;

        return $localeChain;
    }
1036093
public function setCurrent($locale)
	{
		$localeIdentifier = null;

		if ($locale instanceof LocaleInterface) {
			$localeIdentifier = $locale->getId();
		} else {
			$localeIdentifier = $locale;
		}

		$this->current = $this->getLocale($localeIdentifier);
	}
862935
public function handle($locale, $translation, $params = null) {
		return preg_replace_callback('~\[([a-z]+)(?:=([a-z0-9_]+))?\](.*?)\[/\1\]~', function($match) use($locale, $params) {
			list($origin, $bbcode, $bbargument, $value) = $match;
			
			// Plural
			if ($bbcode === 'plural') {
				if (empty($bbargument)) {
					throw new NoRequiredParam('Name of the plural number parameter must be specified in the BBCode');
				}
				
				if (! isset($params[$bbargument])) {
					throw new NoRequiredParam('Required parameter "' . $bbargument . '" is absent');
				}
				
				$result = $this->choosePlural($params[$bbargument], $value, $locale);
				
				return $this->handle($locale, $result, $params);
			}
			
			// Recursive BBCodes
			if (preg_match('~\[[a-z]+(?:=[a-z0-9_]+)?\]~', $value)) {
				$value = $this->handle($locale, $value, $params);
			}
			
			// Try the BBCode action callback
			if (isset($this->actions[$bbcode])) {
				return $this->actions[$bbcode]($value, $bbcode, $origin);
			}
			
			// Try the BBCode formatter
			$formatter = $this->getFormattersInitializer()->initialize(ucfirst($bbcode));
			
			$formatterParams = [];

			if (isset($bbargument[0])) {
				$formatterParams['primary'] = $bbargument;
			}

			if (preg_match($this->getParamExpression(), $value, $valueMatch)) {
				$value = trim($valueMatch[1]);

				if ($params === null || ! isset($params[$value])) {
					throw new NoRequiredParam('Required parameter "' . $value . '" is absent');
				}

				$paramPrefix = $value . '.';

				foreach ($params as $paramKey => $paramValue) {
					if (strpos($paramKey, $paramPrefix) === 0) {
						$formatterParams[str_replace($paramPrefix, '', $paramKey)] = $paramValue;
					}
				}

				return $formatter->format($params[$value], $formatterParams, $locale);
			}

			return $formatter->format($value, $formatterParams, $locale);
		}, $translation);
	}
386315
public static final function configuration(string $locale) {
    if (!empty($locale)) {
      Lang::$locale = $locale;
    } else {
      Lang::$locale = Lang::STANDARD_LOCALE;
    }
    return null;
  }
1111953
public function setLocale($locale = null)
    {
        if ($locale !== false) {
            // require_once 'Zend/Locale.php';
            $locale = Zend_Locale::findLocale($locale);
            if (strlen($locale) < 4) {
                // require_once 'Zend/Validate/Exception.php';
                throw new Zend_Validate_Exception('Region must be given for IBAN validation');
            }
        }

        $this->_locale = $locale;
        return $this;
    }
462676
public static function executeWithLocale($locale, $func)
    {
        $currentLocale = static::getLocale();
        $result = call_user_func($func, static::setLocale($locale) ? static::getLocale() : false, static::translator());
        static::setLocale($currentLocale);

        return $result;
    }
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();
    }
434923
public static function fromLocale(string $locale): LocaleFormatter
    {
        $formatter = new NumberFormatter((string) $locale, NumberFormatter::CURRENCY);

        return new self($formatter);
    }