localeFromString function
Convert string locale localeString
to Locale
Implementation
@Deprecated('Deprecated on Easy Localization 3.0')
Locale localeFromString(String localeString) {
final localeList = localeString.split('_');
switch (localeList.length) {
case 2:
return localeList.last.length == 4 // scriptCode length is 4
? Locale.fromSubtags(
languageCode: localeList.first,
scriptCode: localeList.last,
)
: Locale(localeList.first, localeList.last);
case 3:
return Locale.fromSubtags(
languageCode: localeList.first,
scriptCode: localeList[1],
countryCode: localeList.last,
);
default:
return Locale(localeList.first);
}
}