Skip to content

Commit

Permalink
Use plural_form to pluralize fruits/deskitems
Browse files Browse the repository at this point in the history
Summary:
fruits and desk items are now Plural items, so plural_form needs to be
used to pluralize them. I'm not sure if this is the correct approach (as @john
didn't do this before) but it does make the exercise appear correctly.
Sometimes there are errors because "X" and "Y" aren't plural objects, but that
isn't shown to the user and looks fine.

Test Plan:
Go to
http://sandcastle.khanacademy.org/media/castles/xymostech:fix-linear-equations/exercises/interpreting_linear_equations.html?debug&problem=increase&seed=21
See that it doesn't show "undefined" everywhere

Reviewers: eater, alpert, john

Reviewed By: john

Differential Revision: http://phabricator.khanacademy.org/D2359
  • Loading branch information
Emily Eisenberg committed May 20, 2013
1 parent 1aa7636 commit ad0177c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion utils/word-problems.js
Expand Up @@ -105,6 +105,11 @@ $.extend(KhanUtil, {

var pluralizeWord = function(word) {

// Check if this is a new Plural object, and just use that plural
if (word && word.plural) {
return word.plural(2);
}

// noone really needs extra spaces at the edges, do they?
word = $.trim(word);

Expand Down Expand Up @@ -175,7 +180,8 @@ $.extend(KhanUtil, {
}

return value + " " + arg1;
} else if (typeof value === "string") {
} else if (typeof value === "string" || typeof value === "object") {
// We need to accept objects here as well for new Plural objects
var plural = pluralizeWord(value);
if (typeof arg1 === "string" && arguments.length === 3) {
plural = arg1;
Expand Down

0 comments on commit ad0177c

Please sign in to comment.