From 92745f717d96b17ddb066e15a003b4e09c149691 Mon Sep 17 00:00:00 2001 From: Arian Baishya Date: Wed, 26 Jul 2023 22:30:24 -0500 Subject: [PATCH 1/2] Use translated string value rather than raw value --- lib/pages/settings/settings.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pages/settings/settings.dart b/lib/pages/settings/settings.dart index e8a29398..19a9e057 100644 --- a/lib/pages/settings/settings.dart +++ b/lib/pages/settings/settings.dart @@ -629,7 +629,7 @@ class GeneralConfigPage extends StatelessWidget { values: SortType.values, groupValue: store.defaultSortType, onChanged: (value) => store.defaultSortType = value, - mapValueToString: (value) => value.value, + mapValueToString: (value) => value.tr(context), buttonBuilder: (context, displayValue, onPressed) => FilledButton( onPressed: onPressed, From 9b846d13bb309b458171cc199e408c3562106325 Mon Sep 17 00:00:00 2001 From: Arian Baishya Date: Wed, 26 Jul 2023 22:54:46 -0500 Subject: [PATCH 2/2] Implement fix for "comment sort type" and default listing dropdowns --- lib/l10n/l10n_api.dart | 17 +++++++++++++++++ lib/pages/settings/settings.dart | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/l10n/l10n_api.dart b/lib/l10n/l10n_api.dart index 805a2d41..10398381 100644 --- a/lib/l10n/l10n_api.dart +++ b/lib/l10n/l10n_api.dart @@ -40,6 +40,23 @@ extension SortTypeL10n on SortType { } } +extension CommentSortTypeL10n on CommentSortType { + String tr(BuildContext context) { + switch (this) { + case CommentSortType.hot: + return L10n.of(context).hot; + case CommentSortType.new_: + return L10n.of(context).new_; + case CommentSortType.old: + return L10n.of(context).old; + case CommentSortType.top: + return L10n.of(context).top; + default: + throw Exception('unreachable'); + } + } +} + extension PostListingTypeL10n on PostListingType { String tr(BuildContext context) { switch (this) { diff --git a/lib/pages/settings/settings.dart b/lib/pages/settings/settings.dart index 19a9e057..751d066e 100644 --- a/lib/pages/settings/settings.dart +++ b/lib/pages/settings/settings.dart @@ -653,7 +653,7 @@ class GeneralConfigPage extends StatelessWidget { .sublist(0, CommentSortType.values.length - 1), groupValue: store.defaultCommentSort, onChanged: (value) => store.defaultCommentSort = value, - mapValueToString: (value) => value.value, + mapValueToString: (value) => value.tr(context), buttonBuilder: (context, displayValue, onPressed) => FilledButton( onPressed: onPressed, @@ -680,7 +680,7 @@ class GeneralConfigPage extends StatelessWidget { ], groupValue: store.defaultListingType, onChanged: (value) => store.defaultListingType = value, - mapValueToString: (value) => value.value, + mapValueToString: (value) => value.tr(context), buttonBuilder: (context, displayValue, onPressed) => FilledButton( onPressed: onPressed,