Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use translated string value rather than raw value for post sort, comment sort, and default listing setting dropdowns #454

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/l10n/l10n_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions lib/pages/settings/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
Loading