11import 'package:flutter/material.dart' ;
22import 'package:flutter_bloc/flutter_bloc.dart' ;
33import 'package:ht_dashboard/app_configuration/bloc/app_configuration_bloc.dart' ;
4+ import 'package:ht_dashboard/l10n/app_localizations.dart' ;
45import 'package:ht_dashboard/l10n/l10n.dart' ;
56import 'package:ht_dashboard/shared/constants/app_spacing.dart' ;
67import 'package:ht_dashboard/shared/widgets/widgets.dart' ;
@@ -766,15 +767,14 @@ class _UserPreferenceLimitsFormState extends State<_UserPreferenceLimitsForm> {
766767 @override
767768 Widget build (BuildContext context) {
768769 final userPreferenceConfig = widget.remoteConfig.userPreferenceConfig;
770+ final l10n = context.l10n;
769771
770772 return Column (
771773 children: [
772774 widget.buildIntField (
773775 context,
774- label: 'Followed Items Limit' ,
775- description:
776- 'Maximum number of countries, news sources, or categories this '
777- 'user role can follow (each type has its own limit).' ,
776+ label: _getFollowedItemsLimitLabel (l10n),
777+ description: _getFollowedItemsLimitDescription (l10n),
778778 value: _getFollowedItemsLimit (userPreferenceConfig),
779779 onChanged: (value) {
780780 widget.onConfigChanged (
@@ -790,8 +790,8 @@ class _UserPreferenceLimitsFormState extends State<_UserPreferenceLimitsForm> {
790790 ),
791791 widget.buildIntField (
792792 context,
793- label: 'Saved Headlines Limit' ,
794- description: 'Maximum number of headlines this user role can save.' ,
793+ label: _getSavedHeadlinesLimitLabel (l10n) ,
794+ description: _getSavedHeadlinesLimitDescription (l10n) ,
795795 value: _getSavedHeadlinesLimit (userPreferenceConfig),
796796 onChanged: (value) {
797797 widget.onConfigChanged (
@@ -809,6 +809,50 @@ class _UserPreferenceLimitsFormState extends State<_UserPreferenceLimitsForm> {
809809 );
810810 }
811811
812+ String _getFollowedItemsLimitLabel (AppLocalizations l10n) {
813+ switch (widget.userRole) {
814+ case AppUserRole .guestUser:
815+ return l10n.guestFollowedItemsLimitLabel;
816+ case AppUserRole .standardUser:
817+ return l10n.standardUserFollowedItemsLimitLabel;
818+ case AppUserRole .premiumUser:
819+ return l10n.premiumFollowedItemsLimitLabel;
820+ }
821+ }
822+
823+ String _getFollowedItemsLimitDescription (AppLocalizations l10n) {
824+ switch (widget.userRole) {
825+ case AppUserRole .guestUser:
826+ return l10n.guestFollowedItemsLimitDescription;
827+ case AppUserRole .standardUser:
828+ return l10n.standardUserFollowedItemsLimitDescription;
829+ case AppUserRole .premiumUser:
830+ return l10n.premiumFollowedItemsLimitDescription;
831+ }
832+ }
833+
834+ String _getSavedHeadlinesLimitLabel (AppLocalizations l10n) {
835+ switch (widget.userRole) {
836+ case AppUserRole .guestUser:
837+ return l10n.guestSavedHeadlinesLimitLabel;
838+ case AppUserRole .standardUser:
839+ return l10n.standardUserSavedHeadlinesLimitLabel;
840+ case AppUserRole .premiumUser:
841+ return l10n.premiumSavedHeadlinesLimitLabel;
842+ }
843+ }
844+
845+ String _getSavedHeadlinesLimitDescription (AppLocalizations l10n) {
846+ switch (widget.userRole) {
847+ case AppUserRole .guestUser:
848+ return l10n.guestSavedHeadlinesLimitDescription;
849+ case AppUserRole .standardUser:
850+ return l10n.standardUserSavedHeadlinesLimitDescription;
851+ case AppUserRole .premiumUser:
852+ return l10n.premiumSavedHeadlinesLimitDescription;
853+ }
854+ }
855+
812856 int _getFollowedItemsLimit (UserPreferenceConfig config) {
813857 switch (widget.userRole) {
814858 case AppUserRole .guestUser:
@@ -990,15 +1034,14 @@ class _AdConfigFormState extends State<_AdConfigForm> {
9901034 @override
9911035 Widget build (BuildContext context) {
9921036 final adConfig = widget.remoteConfig.adConfig;
1037+ final l10n = context.l10n;
9931038
9941039 return Column (
9951040 children: [
9961041 widget.buildIntField (
9971042 context,
998- label: 'Ad Frequency' ,
999- description:
1000- 'How often an ad can appear for this user role (e.g., a value '
1001- 'of 5 means an ad could be placed after every 5 news items).' ,
1043+ label: l10n.adFrequencyLabel,
1044+ description: l10n.adFrequencyDescription,
10021045 value: _getAdFrequency (adConfig),
10031046 onChanged: (value) {
10041047 widget.onConfigChanged (
@@ -1011,10 +1054,8 @@ class _AdConfigFormState extends State<_AdConfigForm> {
10111054 ),
10121055 widget.buildIntField (
10131056 context,
1014- label: 'Ad Placement Interval' ,
1015- description:
1016- 'Minimum number of news items that must be shown before the '
1017- 'very first ad appears for this user role.' ,
1057+ label: l10n.adPlacementIntervalLabel,
1058+ description: l10n.adPlacementIntervalDescription,
10181059 value: _getAdPlacementInterval (adConfig),
10191060 onChanged: (value) {
10201061 widget.onConfigChanged (
@@ -1027,10 +1068,8 @@ class _AdConfigFormState extends State<_AdConfigForm> {
10271068 ),
10281069 widget.buildIntField (
10291070 context,
1030- label: 'Articles Before Interstitial Ads' ,
1031- description:
1032- 'Number of articles this user role needs to read before a '
1033- 'full-screen interstitial ad is shown.' ,
1071+ label: l10n.articlesBeforeInterstitialAdsLabel,
1072+ description: l10n.articlesBeforeInterstitialAdsDescription,
10341073 value: _getArticlesBeforeInterstitial (adConfig),
10351074 onChanged: (value) {
10361075 widget.onConfigChanged (
@@ -1198,27 +1237,29 @@ class _AccountActionConfigFormState extends State<_AccountActionConfigForm> {
11981237 super .dispose ();
11991238 }
12001239
1201- String _formatLabel (String enumName) {
1202- // Converts camelCase to Title Case
1203- final spaced = enumName.replaceAllMapped (
1204- RegExp ('([A-Z])' ),
1205- (match) => ' ${match .group (1 )}' ,
1206- );
1207- return '${spaced [0 ].toUpperCase ()}${spaced .substring (1 )} Days' ;
1208- }
1209-
12101240 @override
12111241 Widget build (BuildContext context) {
12121242 final accountActionConfig = widget.remoteConfig.accountActionConfig;
12131243 final relevantActionTypes = _getDaysMap (accountActionConfig).keys.toList ();
1244+ final l10n = context.l10n;
12141245
12151246 return Column (
12161247 children: relevantActionTypes.map ((actionType) {
1248+ final localizedActionType = switch (actionType) {
1249+ FeedActionType .linkAccount => l10n.feedActionTypeLinkAccount,
1250+ FeedActionType .rateApp => l10n.feedActionTypeRateApp,
1251+ FeedActionType .followTopics => l10n.feedActionTypeFollowTopics,
1252+ FeedActionType .followSources => l10n.feedActionTypeFollowSources,
1253+ FeedActionType .upgrade => l10n.feedActionTypeUpgrade,
1254+ FeedActionType .enableNotifications =>
1255+ l10n.feedActionTypeEnableNotifications,
1256+ };
12171257 return widget.buildIntField (
12181258 context,
1219- label: _formatLabel (actionType.name),
1220- description:
1221- 'Minimum number of days before showing the ${actionType .name } prompt.' ,
1259+ label: '$localizedActionType ${l10n .daysSuffix }' ,
1260+ description: l10n.daysBetweenPromptDescription (
1261+ localizedActionType,
1262+ ),
12221263 value: _getDaysMap (accountActionConfig)[actionType] ?? 0 ,
12231264 onChanged: (value) {
12241265 final currentMap = _getDaysMap (accountActionConfig);
0 commit comments