Skip to content

Commit 87824bc

Browse files
committed
feat(l10n): add extension for localized feed decorator type names
- Create new extension on FeedDecoratorType to provide localized string representations - Add l10n method that returns the localized name for each FeedDecoratorType - Cover all cases of FeedDecoratorType in the switch statement - Import necessary packages and libraries
1 parent d087017 commit 87824bc

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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 feed_decorator_type_l10n}
6+
/// Extension on [FeedDecoratorType] to provide localized string representations.
7+
/// {@endtemplate}
8+
extension FeedDecoratorTypeL10n on FeedDecoratorType {
9+
/// Returns the localized name for a [FeedDecoratorType].
10+
String l10n(BuildContext context) {
11+
final l10n = context.l10n;
12+
switch (this) {
13+
case FeedDecoratorType.linkAccount:
14+
return l10n.feedDecoratorTypeLinkAccount;
15+
case FeedDecoratorType.upgrade:
16+
return l10n.feedDecoratorTypeUpgrade;
17+
case FeedDecoratorType.rateApp:
18+
return l10n.feedDecoratorTypeRateApp;
19+
case FeedDecoratorType.enableNotifications:
20+
return l10n.feedDecoratorTypeEnableNotifications;
21+
case FeedDecoratorType.suggestedTopics:
22+
return l10n.feedDecoratorTypeSuggestedTopics;
23+
case FeedDecoratorType.suggestedSources:
24+
return l10n.feedDecoratorTypeSuggestedSources;
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)