Skip to content

Commit 63a3ae0

Browse files
committed
refactor(app_config): Use l10n for labels and descriptions
- Replaced hardcoded labels with localized strings. - Replaced hardcoded descriptions with localized strings. - Improved readability and maintainability. - Simplified code by using localized strings. - Updated UI to reflect localized text.
1 parent 30c29a9 commit 63a3ae0

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed

lib/app_configuration/view/app_configuration_page.dart

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -766,15 +766,14 @@ class _UserPreferenceLimitsFormState extends State<_UserPreferenceLimitsForm> {
766766
@override
767767
Widget build(BuildContext context) {
768768
final userPreferenceConfig = widget.remoteConfig.userPreferenceConfig;
769+
final l10n = context.l10n;
769770

770771
return Column(
771772
children: [
772773
widget.buildIntField(
773774
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).',
775+
label: l10n.followedItemsLimitLabel,
776+
description: l10n.followedItemsLimitDescription,
778777
value: _getFollowedItemsLimit(userPreferenceConfig),
779778
onChanged: (value) {
780779
widget.onConfigChanged(
@@ -790,8 +789,8 @@ class _UserPreferenceLimitsFormState extends State<_UserPreferenceLimitsForm> {
790789
),
791790
widget.buildIntField(
792791
context,
793-
label: 'Saved Headlines Limit',
794-
description: 'Maximum number of headlines this user role can save.',
792+
label: l10n.savedHeadlinesLimitLabel,
793+
description: l10n.savedHeadlinesLimitDescription,
795794
value: _getSavedHeadlinesLimit(userPreferenceConfig),
796795
onChanged: (value) {
797796
widget.onConfigChanged(
@@ -990,15 +989,14 @@ class _AdConfigFormState extends State<_AdConfigForm> {
990989
@override
991990
Widget build(BuildContext context) {
992991
final adConfig = widget.remoteConfig.adConfig;
992+
final l10n = context.l10n;
993993

994994
return Column(
995995
children: [
996996
widget.buildIntField(
997997
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).',
998+
label: l10n.adFrequencyLabel,
999+
description: l10n.adFrequencyDescription,
10021000
value: _getAdFrequency(adConfig),
10031001
onChanged: (value) {
10041002
widget.onConfigChanged(
@@ -1011,10 +1009,8 @@ class _AdConfigFormState extends State<_AdConfigForm> {
10111009
),
10121010
widget.buildIntField(
10131011
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.',
1012+
label: l10n.adPlacementIntervalLabel,
1013+
description: l10n.adPlacementIntervalDescription,
10181014
value: _getAdPlacementInterval(adConfig),
10191015
onChanged: (value) {
10201016
widget.onConfigChanged(
@@ -1027,10 +1023,8 @@ class _AdConfigFormState extends State<_AdConfigForm> {
10271023
),
10281024
widget.buildIntField(
10291025
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.',
1026+
label: l10n.articlesBeforeInterstitialAdsLabel,
1027+
description: l10n.articlesBeforeInterstitialAdsDescription,
10341028
value: _getArticlesBeforeInterstitial(adConfig),
10351029
onChanged: (value) {
10361030
widget.onConfigChanged(
@@ -1198,27 +1192,29 @@ class _AccountActionConfigFormState extends State<_AccountActionConfigForm> {
11981192
super.dispose();
11991193
}
12001194

1201-
String _formatLabel(String enumName) {
1195+
String _formatLabel(String enumName, AppLocalizations l10n) {
12021196
// Converts camelCase to Title Case
12031197
final spaced = enumName.replaceAllMapped(
12041198
RegExp('([A-Z])'),
12051199
(match) => ' ${match.group(1)}',
12061200
);
1207-
return '${spaced[0].toUpperCase()}${spaced.substring(1)} Days';
1201+
return '${spaced[0].toUpperCase()}${spaced.substring(1)} ${l10n.daysSuffix}';
12081202
}
12091203

12101204
@override
12111205
Widget build(BuildContext context) {
12121206
final accountActionConfig = widget.remoteConfig.accountActionConfig;
12131207
final relevantActionTypes = _getDaysMap(accountActionConfig).keys.toList();
1208+
final l10n = context.l10n;
12141209

12151210
return Column(
12161211
children: relevantActionTypes.map((actionType) {
12171212
return widget.buildIntField(
12181213
context,
1219-
label: _formatLabel(actionType.name),
1220-
description:
1221-
'Minimum number of days before showing the ${actionType.name} prompt.',
1214+
label: _formatLabel(actionType.name, l10n),
1215+
description: l10n.daysBetweenPromptDescription(
1216+
actionType: actionType.name,
1217+
),
12221218
value: _getDaysMap(accountActionConfig)[actionType] ?? 0,
12231219
onChanged: (value) {
12241220
final currentMap = _getDaysMap(accountActionConfig);

0 commit comments

Comments
 (0)