Skip to content

Commit 7958d2f

Browse files
committed
feat(l10n): add localization extension for PushNotificationProvider
- Create new extension file for PushNotificationProvider enum - Implement l10n method to return localized string representations - Add cases for firebase and oneSignal push notification providers
1 parent b32a5c3 commit 7958d2f

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

lib/app_configuration/widgets/push_notification_settings_form.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:core/core.dart';
22
import 'package:flutter/material.dart';
3+
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/app_localizations.dart';
34
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart';
45
import 'package:flutter_news_app_web_dashboard_full_source_code/shared/extensions/push_notification_provider_l10n.dart';
56
import 'package:flutter_news_app_web_dashboard_full_source_code/shared/extensions/push_notification_subscription_delivery_type_l10n.dart';

lib/shared/extensions/extensions.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ export 'content_status_l10n.dart';
66
export 'dashboard_user_role_l10n.dart';
77
export 'feed_decorator_type_l10n.dart';
88
export 'in_article_ad_slot_type_l10n.dart';
9+
export 'push_notification_provider_l10n.dart';
10+
export 'push_notification_subscription_delivery_type_l10n.dart';
911
export 'source_type_l10n.dart';
1012
export 'string_truncate.dart';
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import 'package:core/core.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart';
4+
5+
/// Extension to localize the [PushNotificationProvider] enum.
6+
extension PushNotificationProviderL10n on PushNotificationProvider {
7+
/// Returns the localized string representation of the
8+
/// [PushNotificationProvider].
9+
String l10n(BuildContext context) {
10+
final l10n = AppLocalizationsX(context).l10n;
11+
switch (this) {
12+
case PushNotificationProvider.firebase:
13+
return l10n.pushNotificationProviderFirebase;
14+
case PushNotificationProvider.oneSignal:
15+
return l10n.pushNotificationProviderOneSignal;
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)