Skip to content

Commit d087017

Browse files
committed
feat(l10n): add localization extension for AppUserRole
- Create new extension on AppUserRole to provide localized string representations - Add l10n method that returns localized name based on user role - Include cases for guestUser, standardUser, and premiumUser - Update imports to include necessary packages and localization files
1 parent 0eb6464 commit d087017

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import 'package:core/core.dart';
2+
import 'package:flutter/widgets.dart';
3+
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart';
4+
5+
/// {@template app_user_role_l10n}
6+
/// Extension on [AppUserRole] to provide localized string representations.
7+
/// {@endtemplate}
8+
extension AppUserRoleL10n on AppUserRole {
9+
/// Returns the localized name for an [AppUserRole].
10+
String l10n(BuildContext context) {
11+
final l10n = context.l10n;
12+
switch (this) {
13+
case AppUserRole.guestUser:
14+
return l10n.guestUserTab;
15+
case AppUserRole.standardUser:
16+
return l10n.authenticatedUserTab; // Using authenticatedUserTab for standardUser
17+
case AppUserRole.premiumUser:
18+
return l10n.premiumUserTab;
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)