Parses the given string and returns its Locale representation.

@param string $value The value to parse.
@return Locale The Locale representation of the given value or a null value.
542459
public static function fromString(string $value)
    {
        $locale = preg_split('/-|_/', $value, 2);
        $language = null;
        $culture = null;

        if (isset($locale[0])) {
            $language = $locale[0];
        }

        if (isset($locale[1])) {
            $culture = $locale[1];
        }

        return new static($language, $culture);
    }
510814
private function translate( $value ) {
		$textdomain = $this->get_textdomain();
		if ( ! empty( $textdomain ) ) {
			$translated = __( $value, $textdomain );
			if ( $value !== $translated ) {
				return $translated;
			}
		}

		return __( $value, TECHNOTE_PLUGIN );
	}
112942
public function parse($value)
    {
        switch (true) {

            case is_string($value):
                $this->initFromString($value);
                break;

            case is_int($value):
                $this->initFromInteger($value);
                break;

            case is_array($value):
                $this->initFromArray($value);
                break;

            case is_object($value):
                $this->initFromObject($value);
                break;

            case is_null($value):
                $this->initFromArray([255, 255, 255, 0]);
                break;

            default:
                throw new \Intervention\Image\Exception\NotReadableException(
                    "Color format ({$value}) cannot be read."
                );
        }

        return $this;
    }
81817
public static function decode(string $value)
    {
        $stdObject = json_decode($value);
        // catch error if it occurs
        self::catchError();

        if (self::getError()) {
            return self::getError();
        }

        return $stdObject;
    }
214196
protected function formatValue($value)
    {
        if (is_string($value)
            && !is_numeric($value)
        ) {
            $value = html_entity_decode($value, ENT_COMPAT, 'UTF-8');
        } elseif ($value === false) {
            $value = 0;
        }

        $value = $this->formatFormulas($value);

        if (is_string($value)
            && (strpos($value, '"') !== false
                || strpos($value, $this->separator) !== false)
        ) {
            $value = '"' . str_replace('"', '""', $value) . '"';
        }

        // in some number formats (e.g. German), the decimal separator is a comma
        // we need to catch and replace this
        if (is_numeric($value)) {
            $value = (string)$value;
            $value = str_replace(',', '.', $value);
        }

        return $value;
    }
733751
private static function _parseDateTimeString($value)
    {
        $result = @preg_match('/^\d\d\d\d-\d?\d-\d?\d \d\d:\d\d:\d\d$/', $value);
        if ($result !== 1)
            return null;
        $timestamp = strtotime($value);
        if ($timestamp === false)
            return null;

        return $timestamp;
    }
756936
public function parse($value)
    {
        if (is_array($value)) {
            return $this->parseSet($value);
        } else {
            return $this->parseValue($value);
        }
    }
1304396
public static function load($value)
  {
    $value = trim($value);

    if (0 == strlen($value)) {
      return '';
    }

    if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
      $mbEncoding = mb_internal_encoding();
      mb_internal_encoding('ASCII');
    }

    switch ($value[0]) {
      case '[':
        $result = self::parseSequence($value);
        break;
      case '{':
        $result = self::parseMapping($value);
        break;
      default:
        $result = self::parseScalar($value);
    }

    if (isset($mbEncoding)) {
      mb_internal_encoding($mbEncoding);
    }

    return $result;
  }
391452
protected static function parseValue($value)
    {
        if ($value instanceof \DateTime) {
            return 'new \\DateTime(' . \var_export($value->format('c'), true) . ')';
        }

        if (!\is_string($value)) {
            return \var_export($value, true);
        }

        if (\preg_match('/%([a-zA-Z0-9_:\\\]+)(?::(.*))?%/', $value, $matches)) {
            $function = $matches[1];

            if (!\function_exists($function)) {
                return $value;
            }

            if (!isset($matches[2])) {
                return $function . '()';
            }

            $args = \explode(',', $matches[2]);
            foreach ($args as &$a) {
                $a = static::parseConstant(\trim($a));
            }

            return $function . '(' . \implode(', ', $args) . ')';
        }

        return static::parseConstant($value);
    }
947296
public function filter($value)
    {
        return true === array_key_exists((string)$value, $this->translations) ? $this->translations[$value] : null;
    }
1188099
public static function string($value)
    {
        if (static::stringable($value)) {
            $value = (string) $value;
        } else {
            $value = null;
        }

        return $value;
    }
682103
protected function getPluralForm($value)
    {
        // Strip non-plural keys away
        if (is_array($value)) {
            $forms = i18n::config()->uninherited('plurals');
            $forms = array_combine($forms, $forms);
            return array_intersect_key($value, $forms);
        }

        // Parse from string
        // Note: Risky outside of 'en' locale.
        return i18n::parse_plurals($value);
    }
299076
protected static function parse($value)
    {
        $segments = explode('+', $value);

        // check if the cookie is invalid.
        if (!(count($segments) >= 2)) {
            return null;
        }

        $value = implode('+', array_slice($segments, 1));

        // check the SHA-1 hash from the cookie.
        if ($segments[0] == static::hash($value)) {
            return $value;
        }

        return null;
    }
403664
public function parse(string $value)
    {
        if (false === \preg_match('//u', $value)) {
            throw new ParseException('The YAML value does not appear to be valid UTF-8.', -1, null, $this->filename);
        }

        $this->refs = [];

        $data = null;

        try {
            $data = $this->doParse($value);
        } finally {
            $this->lines = [];
            $this->currentLine = '';
            $this->refs = [];
            $this->skippedLineNumbers = [];
            $this->locallySkippedLineNumbers = [];
        }

        return $data;
    }
1306530
private function getValue(string $key, $value = null)
    {
        if (! is_null($this->language)) {
            $key = $this->language.'.'.$key;
        }

        if (! is_null($this->prefix)) {
            $key = $this->prefix.'.'.$key;
        }

        $data = $this->data->getContent($key);

        // default value
        if (is_null($data)) {
            return $value;
        }

        if ($value instanceof \Closure) {
            return $value($data, $this->data);
        }

        return $data;
    }
1035037
protected function getStringValue($value)
    {
        if ($value === true) {
            return 'true';
        } elseif ($value === false) {
            return 'false';
        } elseif ($value === null) {
            return 'null';
        } elseif (is_string($value)) {
            return "\"$value\"";
        }

        return rtrim(print_r($value, true));
    }
688003
public static function parseString($value) {
        if (null === $value) {
            return null;
        }
        if (0 === preg_match("/^[0-9]{1,}(\.[0-9]{0,})?$/", $value)) {
            throw new FloatArgumentException($value);
        }
        return floatval($value);
    }