Skip to content

Instantly share code, notes, and snippets.

@danbernier
Forked from sukima/issue.js
Last active December 19, 2015 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danbernier/5950117 to your computer and use it in GitHub Desktop.
Save danbernier/5950117 to your computer and use it in GitHub Desktop.
This is more what I was after - this way, ratingText is created once, AND it's private.
var getRatingText = (function() {
var ratingText = {
singular: {
"Closed": L("1_person_voted_to_get_this_issue_fixed", "1 person voted to get this issue fixed"),
"Archived": L("1_person_voted_to_get_this_issue_fixed", "1 person voted to get this issue fixed"),
default: L("1_person_wants_this_fixed", "1 person wants this fixed")
},
plural: {
"Closed": L("people_voted_to_get_this_issue_fixed", "%s people voted to get this issue fixed"),
"Archived": L("people_voted_to_get_this_issue_fixed", "%s people voted to get this issue fixed"),
default: L("people_want_this_fixed", "%s people want this fixed")
}
};
return function(rating, status) {
if (Number(rating) === 1) {
return ratingText.singular[status] || ratingText.singular.default;
}
else {
return String.format(
ratingText.plural[status] || ratingText.plural.default,
rating
);
}
}
)();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment