Returns a site handle based on a given locale.

@param string $locale

@return string
325337
private function locale2handle (string $locale): string
	{
		if (
			!preg_match('/^' . HandleValidator::$handlePattern . '$/', $locale) ||
			in_array(strtolower($locale), HandleValidator::$baseReservedWords, true)
		) {
			$localeParts = array_filter(preg_split('/[^a-zA-Z0-9]/', $locale));

			return $localeParts ? '_' . implode('_', $localeParts) : '';
		}

		return $locale;
	}
978176
public function find($locale)
    {
        if (null === static::$language) {
            foreach ($this->fetchAll() as $item) {
                if ($item->locale() == $locale || $item->iso6391() == $locale) {
                    static::$language = $item;
                    break;
                }
            }
        }

        return static::$language;
    }
1322789
protected function getFormFieldName($locale = null)
    {
        if ( ! $locale) {
            return $this->field->key();
        }

        return $this->field->key() . '[' . $locale . ']';
    }
386315
public static final function configuration(string $locale) {
    if (!empty($locale)) {
      Lang::$locale = $locale;
    } else {
      Lang::$locale = Lang::STANDARD_LOCALE;
    }
    return null;
  }
1075766
protected function getFallbackLocale($locale)
    {
        if ($position = strpos($locale, '-')) {
            $target = substr($locale, 0, $position);
            $available = $this->getLocaleOptions();
            if (isset($available[$target])) {
                return $target;
            }
        }

        return Config::get('app.fallback_locale');
    }
164910
public function getLinkingMode($locale)
    {
        if ($this->owner->hasMethod('canViewInLocale') && !$this->owner->canViewInLocale($locale)) {
            return 'invalid';
        }

        if ($locale === FluentState::singleton()->getLocale()) {
            return 'current';
        }

        return 'link';
    }
777456
protected function parseLocale($locale)
	{
		if ( ! is_null($locale))
		{
			return array_filter(array($locale, $this->fallback));
		}
		else
		{
			return array_filter(array($this->locale, $this->fallback));
		}
	}
372363
public static function getDependency($locale) {
		$locale = PropelL10n::normalize($locale);
		if (self::hasDependency($locale)) {
			return self::$dependencies[$locale];
		}
		
		return null;
	}
858016
public function getLocaleName(string $locale, ?string $displayLocale = null): ?string
    {
        return Locales::getName($locale, $displayLocale);
    }
1355686
public function getTranslationFile($locale)
    {
        if (isset($this->locales[$locale]) === false) {
            return null;
        }

        return $this->locales[$locale];
    }
1097692
private function getFallbackLocale( $locale = null )
    {
        if( $locale && $this->isLocaleCountryBased( $locale ) )
        {
            return $this->getLanguageFromCountryBasedLocale( $locale );
        }

        return Config::get( 'translatable.fallback_locale' );
    }
53234
public function findUsagesByLocales( $locale = null )
    {
        if ( empty( $locale ) )
        {
            $locale = $this->getLocale();
        }

        return $this->getMapper()
                    ->findUsagesByLocales( (array) $locale );
    }
317153
public function scriptDirection($locale = null)
    {
        $dirs = static::config()->get('text_direction');
        if (!$locale) {
            $locale = i18n::get_locale();
        }
        if (isset($dirs[$locale])) {
            return $dirs[$locale];
        }
        $lang = $this->langFromLocale($locale);
        if (isset($dirs[$lang])) {
            return $dirs[$lang];
        }
        return 'ltr';
    }
1190523
public static function getLanguageFromLocale($locale)
    {
        if (strpos($locale, '_')) {
            $parts = explode('_', $locale);

            return strtolower($parts[0]);
        }

        return $locale;
    }
328248
public function getI18n( $locale = null )
	{
		$locale = ( $locale !== null ? $locale : $this->getLocale()->getLanguageId() );

		if( !isset( $this->_i18n[$locale] ) ) {
			/// Locale ID %1$s
			throw new MShop_Exception( sprintf( 'Internationalization object not available for "%1$s"', $locale ) );
		}

		return $this->_i18n[$locale];
	}
1207297
public function getTitle($locale = null)
    {
        if ($locale && isset($this->title[$locale])) {
            return $this->title[$locale];
        }

        if (isset($this->title['default'])) {
            return $this->title['default'];
        }

        return $this->getOriginalName();
    }
750284
public function getDisplayedDescription( $locale = self::FALLBACK_LOCALE )
    {
        if ( ! empty( $this->displayDescription[$locale] ) )
        {
            return $this->displayDescription[$locale];
        }

        $language = Locale::getPrimaryLanguage( $locale );

        if ( ! empty( $this->displayDescription[$language] ) )
        {
            return $this->displayDescription[$language];
        }

        if ( ! empty( $this->displayDescription[static::FALLBACK_LOCALE] ) )
        {
            return $this->displayDescription[static::FALLBACK_LOCALE];
        }

        if ( ! empty( $this->description ) && strpos( $this->description, "\n" ) )
        {
            list( $name, $description ) = explode( "\n", $this->description, 2 );
            return $description;
        }

        return $this->description;
    }