normalizeLocale static method
- Removes all spaces (and similar chars that are generally removed with the trim method).
- Turns all hyphens into underscores.
- Turns double (or more underscores) into a single underscore.
- Trims leading and trailing underscores.
- Turns the locale into lowercase.
- Throws a TranslationsException if the locale has more than 20 characters or fewer than 2.
Examples:
en_us_
becomes en_us
.
en__us_
becomes en_us
.
en-us
becomes en_us
.
en-
becomes en
.
Implementation
static String normalizeLocale(String locale) => utils.normalizeLocale(locale);