parseLocale static method
Implementation
static Locale? parseLocale(Object? locale) {
if (locale is Locale) return locale;
if (locale is! String || locale.isEmpty) return null;
final codes = locale.split("_");
if (codes.isEmpty) return null;
String? countryCode = codes.length == 2 ? codes.last : null;
return Locale(codes.first, countryCode);
}