IntlLocale constructor
IntlLocale(
- dynamic locale
Dynamic parsing and instantiation.
Implementation
factory IntlLocale(dynamic locale) {
if (locale == null) return IntlLocale.getDefaultIntlLocale();
if (locale is IntlLocale) {
return locale;
}
if (locale is List) {
if (locale.isEmpty) return getDefaultIntlLocale();
String lang = locale[0];
String? reg = locale.length > 1 ? locale[1] : null;
return IntlLocale.langReg(lang, reg);
} else if (locale is Map) {
if (locale.isEmpty) return IntlLocale.getDefaultIntlLocale();
String? lang = locale['language'] ?? locale['lang'];
if (lang == null || lang.isEmpty) {
return IntlLocale.getDefaultIntlLocale();
}
String? reg = locale['region'] ?? locale['reg'];
return IntlLocale.langReg(lang, reg);
}
return IntlLocale.code('$locale');
}