public static function sanitizeLocale($locale, $default = null)
    {
        if ($locale instanceof Locale) {
            return $locale->getLocale();
        }

        if ($default) {
            $default = Locale::sanitizeLocale($default, null);
        }

        $locale = (string) $locale;
        $locale = trim($locale);

        if (!$locale || !preg_match("/^" . Locale::REGEX_LOCALE . "$/ui", $locale, $found)) {
            return $default;
        }

        $found['language'] = Text::toLower($found['language']);
        $found['country']  = Text::toUpper($found['country']);

        return sprintf("%s_%s", $found['language'], $found['country']);
    }