-
Notifications
You must be signed in to change notification settings - Fork 772
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
Fix OrderingFilter label translation #546
Fix OrderingFilter label translation #546
Conversation
Thanks @ad-m! |
@@ -656,7 +656,7 @@ def normalize_fields(cls, fields): | |||
|
|||
def build_choices(self, fields, labels): | |||
ascending = [ | |||
(param, labels.get(field, pretty_name(param))) | |||
(param, labels.get(field, _(pretty_name(param)))) | |||
for field, param in fields.items() | |||
] | |||
descending = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use:
descending = [
('-%s' % pair[0], labels.get('-%s' % pair[0], self.descending_fmt % pair[1]))
for pair in ascending
]
to support translation of label for descending options (eg, '-username'). There is no reason to not support them. In some cases it can improve UX experience by naming orders in more natural ways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not a bad point. It's also a fairly trivial thing to add. Currently updating the PR to include this & your corresponding test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ad-m - see the latest commit.
bca402d
to
6955fd2
Compare
6955fd2
to
b63d222
Compare
LGTM! 👍 |
Supersedes and resolves #543.
This also adds descending options to
OrderingFilter.field_labels
.