-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add track-record value translation tag (#5305)
* add track-record value translation tag * add context to the track record tag labels * Update bg_selector_tags.py
- Loading branch information
Showing
5 changed files
with
52 additions
and
32 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
network-api/networkapi/buyersguide/templates/fragments/it_uses.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
network-api/networkapi/buyersguide/templates/fragments/signup_requirement.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
network-api/networkapi/buyersguide/templatetags/bg_selector_tags.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from django import template | ||
from django.utils.translation import gettext, pgettext | ||
|
||
register = template.Library() | ||
|
||
|
||
@register.filter | ||
def yes_no(value): | ||
"""Converts boolean to yes or no string""" | ||
if value is None: | ||
return gettext('Unknown') | ||
# Python doesn't have a ternary, so we rely on | ||
# type coercion to turn False into 0 and True | ||
# into 1, and using that as list index. | ||
return (gettext('No'), gettext('Yes'))[value] | ||
|
||
|
||
@register.filter | ||
def extended_yes_no(value): | ||
"""Converts quad-state to human readable string""" | ||
if value == 'U': | ||
return gettext('Unknown') | ||
if value == 'NA': | ||
return gettext('N/A') | ||
if value == 'Yes': | ||
return gettext('Yes') | ||
if value == 'No': | ||
return gettext('No') | ||
return value | ||
|
||
|
||
@register.filter | ||
def track_record(value): | ||
""" | ||
effects localization for company track records. While it might | ||
seem easier to just return gettext(value), we want to be explicit | ||
about the possible options, and the context in which to apply | ||
this tag, rather than a generic "localize" tag. | ||
""" | ||
lcontext = "This is a rating for a company's history concerning privacy" | ||
if value == 'Great': | ||
return pgettext(lcontext, 'Great') | ||
if value == 'Average': | ||
return pgettext(lcontext, 'Average') | ||
if value == 'Needs Improvement': | ||
return pgettext(lcontext, 'Needs Improvement') | ||
if value == 'Bad': | ||
return pgettext(lcontext, 'Bad') | ||
return value |
This file was deleted.
Oops, something went wrong.