extractLocale property
String
get
extractLocale
Implementation
String get extractLocale {
final localePattern = RegExp(r'_([a-zA-Z]{2}(?:_[a-zA-Z]{2})?)\.arb$');
final fileName = path.split('/').last;
final match = localePattern.firstMatch(fileName);
if (match != null) {
return match.group(1) ?? (throw Exception("Locale not found in file name."));
} else {
throw Exception("Locale not found in file name.");
}
}