Files
plezy/lib/utils/content_rating_formatter.dart
T
Sam Matthews ed668ba0e4 Fix content rating display to remove country prefixes
- Add formatContentRating utility function to strip country codes (gb/, us/, de/, etc.)
- Apply formatter in discover_screen.dart hero section
- Apply formatter in media_detail_screen.dart (badge and info row)
- Ratings now display as '12', 'PG', 'PG-13' instead of 'gb/12', 'us/PG-13'
- Fixes #10
2025-11-04 03:32:28 +00:00

18 lines
584 B
Dart

/// Utility function to format content ratings by removing country prefixes
String formatContentRating(String? contentRating) {
if (contentRating == null || contentRating.isEmpty) {
return '';
}
// Remove common country prefixes like "gb/", "us/", "de/", etc.
// The pattern matches: lowercase letters followed by a forward slash
final regex = RegExp(r'^[a-z]{2,3}/(.+)$', caseSensitive: false);
final match = regex.firstMatch(contentRating);
if (match != null && match.groupCount >= 1) {
return match.group(1) ?? contentRating;
}
return contentRating;
}