parse method

E parse(
  1. String rawLocale
)

Parses the raw locale to get the enum. Fallbacks to base locale.

Implementation

E parse(String rawLocale) {
  final match = RegexUtils.localeRegex.firstMatch(rawLocale);
  if (match == null) {
    return baseLocale;
  }

  return parseLocaleParts(
    languageCode: match.group(1)!,
    scriptCode: match.group(2),
    countryCode: match.group(3),
  );
}