code: def parse_locale(locale: str) -> Locale:
      try:
          return Locale.parse(locale, sep="_")
      except (ValueError, UnknownLocaleError, TypeError) as e:
          raise ValidationError(f"Invalid value for locale: {e}")
  
file_path: mkdocs/mkdocs/localization.py
imports: from __future__ import annotations
  import logging
  import os
  from typing import TYPE_CHECKING, Sequence
  from jinja2.ext import Extension, InternationalizationExtension
  from mkdocs.config.base import ValidationError
label_desc: Use image node_id 1 for calling a global function with example usage: parse_locale(locale) and returns: Locale