locale property

String? get locale

The first language of the Accept-Language header, like th. null when there is none.

Implementation

String? get locale {
  String? header = httpHeaders.value(HttpHeaders.acceptLanguageHeader);
  if (header == null) return null;
  String first = header.split(',').first.split(';').first.trim();
  if (first.isEmpty || first == '*') return null;
  return first.split('-').first.toLowerCase();
}