Skip to content

Commit a74f26e

Browse files
committed
feat(shared): add in-article ad slot type localization extension
- Create new extension on InArticleAdSlotType for localized string representations - Add l10n method to return localized name based on ad slot type - Update extensions.dart to export the new localization extension
1 parent 97a1e03 commit a74f26e

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export 'app_user_role_l10n.dart';
22
export 'content_status_l10n.dart';
33
export 'feed_decorator_type_l10n.dart';
4+
export 'in_article_ad_slot_type_l10n.dart';
45
export 'source_type_l10n.dart';
56
export 'string_truncate.dart';
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 in_article_ad_slot_type_l10n}
6+
/// Extension on [InArticleAdSlotType] to provide localized string representations.
7+
/// {@endtemplate}
8+
extension InArticleAdSlotTypeL10n on InArticleAdSlotType {
9+
/// Returns the localized name for an [InArticleAdSlotType].
10+
String l10n(BuildContext context) {
11+
final l10n = context.l10n;
12+
switch (this) {
13+
case InArticleAdSlotType.belowMainArticleImage:
14+
return l10n.inArticleAdSlotTypeBelowMainArticleImage;
15+
case InArticleAdSlotType.aboveArticleContinueReadingButton:
16+
return l10n.inArticleAdSlotTypeAboveArticleContinueReadingButton;
17+
case InArticleAdSlotType.belowArticleContinueReadingButton:
18+
return l10n.inArticleAdSlotTypeBelowArticleContinueReadingButton;
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)