Skip to content

Commit d6d565a

Browse files
committed
feat(l10n): add extension for localized AdType descriptions
- Create AdTypeL10n extension on AdType enum - Implement l10n method to return localized strings for each AdType - Add import for context.l10n extension
1 parent 3d02471 commit d6d565a

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/material.dart';
3+
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart';
4+
5+
/// Extension on [AdType] to provide localized descriptions.
6+
extension AdTypeL10n on AdType {
7+
/// Returns a localized string for the [AdType] enum value.
8+
String l10n(BuildContext context) {
9+
final l10n = context.l10n;
10+
switch (this) {
11+
case AdType.banner:
12+
return l10n.bannerAdType;
13+
case AdType.native:
14+
return l10n.nativeAdType;
15+
case AdType.interstitial:
16+
return l10n.interstitialAdType;
17+
case AdType.video:
18+
return l10n.videoAdType;
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)