# Khan/khan-exercises

### Subversion checkout URL

You can clone with
or
.

Revert i18n stuff for now

```Test Plan:

Reviewers: alpert, cbhl

Reviewed By: alpert

1 parent 2de2385 commit b122474dc6c972cfcc2700bfbdb6ad682e70e970 beneater committed
4 exercises/arithmetic_word_problems_1.html
 @@ -136,7 +136,7 @@

Some cars were parked in the store(1) store parking lot. - NUM2 more plural('car') plural('parks', NUM2) at the store(1) store, + NUM2 more plural('car') plural('parks', 'park', NUM2) at the store(1) store, and now there plural('is', TOTAL) plural(TOTAL, 'car') in the parking lot.

@@ -183,7 +183,7 @@

plural(NUM1, 'car') plural('was', NUM1) in the store(1) store parking lot. - NUM2 more plural('car', NUM2) plural('parks', NUM2) at the store(1) store. + NUM2 more plural('car', NUM2) plural('parks', 'park', NUM2) at the store(1) store.

How many cars are in the parking lot now?

2  exercises/creating_bar_charts_1.html
 @@ -117,7 +117,7 @@

- NUM plural( RESPONDENT, NUM ) said their + NUM plural( RESPONDENT, NUM ) said plural( randFromArray([ "his", "her" ]), "their", NUM ) favorite SUBJECT was CATEGORIES[ INDEX ]. So the top of the bar for "CATEGORIES[ INDEX ]" should line up with the number

28 exercises/least_common_multiple_and_greatest_common_divisor_word_problems.html
 @@ -379,12 +379,7 @@

- - 1 team with plural( A, "sprinter" )
-
- - plural( F, "team" ) with plural( A / F, "sprinter" ) each
-
+ plural( F, "team" ) with plural( A / F, "sprinter" ) plural( "", "each", F )

@@ -402,12 +397,7 @@

- - 1 team with plural( B, "long-distance runner" )
-
- - plural( F, "team" ) with plural( B / F, "long-distance runner" ) each
-
+ plural( F, "team" ) with plural( B / F, "long-distance runner" ) plural( "", "each", F )

@@ -514,12 +504,7 @@

-
- - plural( F, "basket" ) with plural( A / F, "chocolate chip cookie" ) each
-
+ plural( F, "basket" ) with plural( A / F, "chocolate chip cookie" ) plural( "", "each", F )

@@ -537,12 +522,7 @@

-
- - plural( F, "basket" ) with plural( B / F, "oatmeal cookie" ) each
-
+ plural( F, "basket" ) with plural( B / F, "oatmeal cookie" ) plural( "", "each", F )

 @@ -163,7 +163,7 @@ The LOCATION with the fewest plural( ITEM ) had plural( SOLUTION, ITEM ). The LOCATION with the most plural( ITEM ) had plural( SOLUTION, ITEM). - plural( SOLUTION, LOCATION ) had + plural( SOLUTION, LOCATION ) plural( "has", "have", SOLUTION ) exactly fewer than more than
22 exercises/visualizing_derivatives.html
 @@ -34,22 +34,12 @@
-
-

- A function f(x) is shown in purple. The sliding green window may contain a section of its derivative f'(x). -

-

- Where does the function in the sliding window correspond to f'(x)? -

-
-
-

- A function f(x) is shown in green. The sliding purple window may contain a section of an antiderivative of the function, F(x). -

-

- Where does the function in the sliding window correspond to F(x)? -

-
+

+ A function f(x) is shown in purplegreen. The sliding green windowsliding purple window may contain a section of MOVE_DERIVATIVE ? "its derivative" : "an antiderivative of the function," MOVE_DERIVATIVE ? "f'(x)" : "F(x)". +

+

+ Where does the function in the sliding window correspond to MOVE_DERIVATIVE ? "f'(x)" : "F(x)"? +

181 khan-exercise.js
 @@ -263,23 +263,17 @@ var Khan = (function() { // "Check answer" or in assessmentMode "Submit answer" - set in prepareSite originalCheckAnswerText = "", - issueError = function() { - return \$._("Communication with GitHub isn't working. Please file " + - "the issue manually at GitHub. " + - "Please reference exercise: %s.", exerciseId); - }, + issueError = "Communication with GitHub isn't working. Please file " + + "the issue manually at GitHub. " + + "Please reference exercise: " + exerciseId + ".", issueSuccess = function(url, title, suggestion) { - return \$._("Thank you for your feedback! Your issue has been created " + - "and can be found at the following link: " + - "

%s

%s

", - url, title, suggestion); - }, - issueIntro = function() { - return \$._("Remember to check the hints and double check your " + - "math. All provided information will be public. Thanks for " + - "your help!"); + return ["Thank you for your feedback! Your issue has been created and can be ", + "found at the following link:", + "

", title, "", + "

", suggestion, "

") .append("
\n" + - "\n" + - "\n" + + "\n" + + "\n" + "
") .insertBefore("#problem-and-answer"); @@ -1456,10 +1442,8 @@ var Khan = (function() { timelinecontainer .append("
\n" + - "\n" + - "\n" + + "\n" + + "\n" + "
"); \$("
Started
") @@ -1478,31 +1462,29 @@ var Khan = (function() { thissolutionarea; timelineEvents - .append("
" + - \$.ngettext("%ss", "%ss", value[2]) + "
"); + .append("
" + value[2] + "s
"); thissolutionarea = \$("
") .addClass("user-activity " + value[0]) .appendTo(timelineEvents); if (value[0] === "hint-activity") { - thissolutionarea.attr("title", \$._("Hint used")); + thissolutionarea.attr("title", "Hint used"); thissolutionarea .data("hint", hintNumber) - .prepend(\$.ngettext("Hint #%s", "Hint #%s", hintNumber + 1)); + .prepend("Hint #" + (hintNumber + 1)); hintNumber += 1; } else { // This panel is a solution (or the first panel) thissolutionarea.data("hint", false); if (guess === "Activity Unavailable") { - thissolutionarea.text(\$._("Activity Unavailable")); + thissolutionarea.text(guess); } else { // radio and custom are the only answer types that // can't display its own guesses in the activity bar if (answerType === "radio") { thissolutionarea.append( // Add the guess to the activity bar - \$("

" + guess + - "

").tmpl() + \$("

" + guess + "

").tmpl() ); if (index === userExercise.userActivity.length - 1) { @@ -1510,11 +1492,9 @@ var Khan = (function() { .removeClass("incorrect-activity") .addClass("correct-activity"); - thissolutionarea.attr("title", - \$._("Correct Answer")); + thissolutionarea.attr("title", "Correct Answer"); } else { - thissolutionarea.attr("title", - \$._("Incorrect Answer")); + thissolutionarea.attr("title", "Incorrect Answer"); } } else if (answerType === "custom") { if (index === userExercise.userActivity.length - 1) { @@ -1522,18 +1502,14 @@ var Khan = (function() { .removeClass("incorrect-activity") .addClass("correct-activity"); - thissolutionarea.attr("title", - \$._("Correct Answer")); + thissolutionarea.attr("title", "Correct Answer"); thissolutionarea.append( - \$("

" + - \$._("Answer correct") + "

") + \$("

") ); } else { - thissolutionarea.attr("title", - \$._("Incorrect Answer")); + thissolutionarea.attr("title", "Incorrect Answer"); thissolutionarea.append( - \$("

" + - \$._("Answer incorrect") + "

") + \$("

" + \$._("Problem types:") + "
Problem types:
"); exercises.children(".problems").children().each(function(n, prob) { var probID = \$(prob).attr("id") || n; @@ -1865,8 +1840,7 @@ var Khan = (function() { // If this is a child exercise, show which one it came from if (exercise.data("name") !== exerciseId) { links.append("

Thanks! You're all done testing this exercise.

" + - "

Please copy the text below and send it to us.

") + "

Thanks! You're all done testing this exercise.

" + + "

Please copy the text below and send it to us.

" ); \$("
15 utils/calculator.js
 @@ -361,7 +361,7 @@ return new Parser; CalculatorError.prototype.constructor = CalculatorError; parser.parseError = function parseError(str, hash) { - throw new CalculatorError(\$._("err")); + throw new CalculatorError("err"); }; return _.bindAll({ @@ -386,7 +386,7 @@ return new Parser; if (ans != null) { return ans; } else { - throw new CalculatorError(\$._("Invalid variable ans")); + throw new CalculatorError("Invalid variable ans"); } } else if (_.isNumber(tree)) { return tree; @@ -411,21 +411,21 @@ return new Parser; asin: function(a) { var ans = fromRad(Math.asin(a)); if (isNaN(ans)) { - throw new CalculatorError(\$._("undefined")); + throw new CalculatorError("undefined"); } return ans; }, acos: function(a) { var ans = fromRad(Math.acos(a)); if (isNaN(ans)) { - throw new CalculatorError(\$._("undefined")); + throw new CalculatorError("undefined"); } return ans; }, atan: function(a) { var ans = fromRad(Math.atan(a)); if (isNaN(ans)) { - throw new CalculatorError(\$._("undefined")); + throw new CalculatorError("undefined"); } return ans; } @@ -437,12 +437,11 @@ return new Parser; this, _.map(tree.slice(1), function(t) { return self.evaluate(t, ans); })); } else { - throw new CalculatorError(\$._("err")); + throw new CalculatorError("err"); } } else { throw new CalculatorError( - \$._("Invalid type %s", - Object.prototype.toString.call(tree))); + "Invalid type " + Object.prototype.toString.call(tree)); } },
4 utils/chemistry.js
 @@ -1,6 +1,4 @@ \$.fn["chemistryLoad"] = function() { - // TODO(jeresig): i18n: Currently the names of the atomic elements aren't - // being used in the UI, but if they are, they will need to be translated. var elements = { "Hydrogen": { "symbol" : "H", @@ -2601,7 +2599,7 @@ \$.fn["chemistryLoad"] = function() { }; var periodicTable = \$("
").appendTo("body"); - periodicTable.attr("title", \$._("Periodic table of the elements")); + periodicTable.attr("title", "Periodic table of the elements"); periodicTable.dialog({ autoOpen: false, show: "fade",
55 utils/factoring-expressions.js
 @@ -63,21 +63,17 @@ KhanUtil.exprSetStyle(termB.initial, KhanUtil.BLUE)]}; var initialForm = KhanUtil.parseFormat("#{a^2} - #{b^2}", [KhanUtil.PINK, KhanUtil.BLUE]); var factoredForm = KhanUtil.parseFormat("(#a + #b)(#a - #b)", [KhanUtil.PINK, KhanUtil.BLUE, KhanUtil.PINK, KhanUtil.BLUE]); - hints.push(\$._("

%s

The expression is of the " + - "form %s which is a difference of two squares so we " + - "can factor it as %s

", - KhanUtil.format(coloredExpr), initialForm, factoredForm)); + hints.push("

" + KhanUtil.format(coloredExpr) + "

The expression is of the form " + initialForm + + " which is a difference of two squares so we can factor it as " + factoredForm + "

"); var strA = KhanUtil.parseFormat("#a", [KhanUtil.PINK]); var strB = KhanUtil.parseFormat("#b", [KhanUtil.BLUE]); - hints.push(\$._("

What are the values of %s and %s?

", strA, strB)); + hints.push("

What are the values of " + strA + " and " + strB + "?

"); var varA = {op: "var", args: ["a"]}; var varB = {op: "var", args: ["b"]}; var exprA = {op: "=", args: [varA, {op: "sqrt", args: [termA.initial]}, termA.sqrt], style: KhanUtil.PINK}; var exprB = {op: "=", args: [varB, {op: "sqrt", args: [termB.initial]}, termB.sqrt], style: KhanUtil.BLUE}; hints.push("

" + KhanUtil.format(exprA) + "

" + KhanUtil.format(exprB) + "

"); - hints.push(\$._("

Use the values we found for %s and " + - "%s to complete the factored expression, " + - "%s

", strA, strB, factoredForm)); + hints.push("

Use the values we found for " + strA + " and " + strB + " to complete the factored expression, " + factoredForm + "

"); var coloredFactored = KhanUtil.exprClone(solution); for (var iArg1 = 0; iArg1 < 2; iArg1++) { var colors = [KhanUtil.PINK, KhanUtil.BLUE]; @@ -85,8 +81,7 @@ coloredFactored.args[iArg1].args[iArg2] = KhanUtil.exprSetStyle(coloredFactored.args[iArg1].args[iArg2], colors[iArg2]); } } - hints.push(\$._("

So we can factor the expression as: " + - "%s

", KhanUtil.format(coloredFactored))); + hints.push("

So we can factor the expression as:" + KhanUtil.format(coloredFactored) + ""); } return {solution: solution, hints: hints}; }; @@ -318,13 +313,10 @@ } var hint = ""; if (listFactors.length === 1) { - return hint + \$._("

The terms have one common factor: %s.

", - strListFactors); + return hint + "

The terms have one common factor: " + strListFactors + ".

"; } else { var gcf = KhanUtil.format(KhanUtil.exprSetStyle(KhanUtil.genExprFromExpFactors(factors, occFactors), KhanUtil.BLUE)); - return hint + \$._("

The terms have these common factors: %s, so " + - "the greatest common factor is %s.

", - strListFactors, gcf); + return hint + "

The terms have these common factors: " + strListFactors + ", so the greatest common factor is " + gcf + ".

"; } }; @@ -338,9 +330,7 @@ } expr = KhanUtil.simplify(expr, KhanUtil.simplifyOptions.checkInput); - hints.push(\$._("

%s

We start by decomposing " + - "each term into a product of its most simple factors.

", - KhanUtil.format(expr))); + hints.push("

" + KhanUtil.format(expr) + "

We start by decomposing each term into a product of its most simple factors.

"); for (var iTerm = 0; iTerm < nbTerms; iTerm++) { var mergedOccFactors = mergeOccFactors(sharedOccFactors, termsOccFactors[iTerm]); @@ -350,13 +340,8 @@ } hints.push(genHintListFactors(factors, sharedOccFactors)); - hints.push(\$._("

We can rewrite the expression as: " + - "%s.

", - KhanUtil.format({op: "+", args: genAllTermsMarkShared(factors, - sharedOccFactors, termsOccFactors, colors)}))); - hints.push(\$._("

We now rewrite the expression as a product: " + - "%s.

", KhanUtil.format(genFullExpr(factors, - sharedOccFactors, termsOccFactors, true)))); + hints.push("

We can rewrite the expression as: " + KhanUtil.format({op: "+", args: genAllTermsMarkShared(factors, sharedOccFactors, termsOccFactors, colors)}) + ".

"); + hints.push("

We now rewrite the expression as a product: " + KhanUtil.format(genFullExpr(factors, sharedOccFactors, termsOccFactors, true)) + ".

"); return hints; }; @@ -398,30 +383,24 @@ var sharedOccFactors = exprFactors.sharedOccFactors; var termsOccFactors = exprFactors.termsOccFactors; - var hints = [\$._("

To factor this expression, we start by looking at the different terms of the sum and find all of their common factors. We can then rewrite the expression as a product between these common factors and what's left of the different terms once we remove these factors.

")]; + var hints = ["

To factor this expression, we start by looking at the different terms of the sum and find all of their common factors. We can then rewrite the expression as a product between these common factors and what's left of the different terms once we remove these factors.

"]; var detailedHints = genHintsDecomposeAllFactors(factors, sharedOccFactors, termsOccFactors); var solution = genFullExpr(factors, sharedOccFactors, termsOccFactors); if (options.factorDiffOfSquares) { - var hint = \$._("

We obtain the following expression: %s

", - KhanUtil.getSubHints("common-factors", - \$._("Show explanation"), detailedHints)); + var hint = "

We obtain the following expression: " + KhanUtil.getSubHints("common-factors", "Show explanation", detailedHints); hint += "

" + KhanUtil.format(solution) + "

"; hints.push(hint); - hints.push(\$._("

Can we factor this expression even more?

")); + hints.push("

Can we factor this expression even more?

"); for (var iArg = 0; iArg < solution.args.length; iArg++) { var arg = solution.args[iArg]; var solvedArg = solveDiffOfSquaresExercise(arg, options); if (solvedArg === undefined) { continue; } - hints.push(\$._("

This part of the expression can be factored: " + - "%s

", KhanUtil.format(arg))); - var hint = \$._("

We recognize and factor a difference of " + - "squares, and obtain the following expression: %s

", - KhanUtil.getSubHints("diff-squares-" + iArg, - \$._("Show explanation"), solvedArg.hints)); + hints.push("

This part of the expression can be factored: " + KhanUtil.format(arg) + "

"); + var hint = "

We recognize and factor a difference of squares, and obtain the following expression: " + KhanUtil.getSubHints("diff-squares-" + iArg, "Show explanation", solvedArg.hints); solution.args[iArg] = solvedArg.solution; hint += "

" + KhanUtil.format(solution); hints.push(hint); @@ -440,9 +419,7 @@ } else if (options.factorWithDiffOfSquares === "(ab^2-cd^2)=a(b - d)(b + d)") { } - hints.push(\$._("

There is nothing left to " + - "factor using this approach. The answer is : %s

", - KhanUtil.format(solution))); + hints.push("

There is nothing left to factor using this approach. The answer is : " + KhanUtil.format(solution) + "

"); return {hints: hints, solution: solution}; };
31 utils/graphie-helpers-arithmetic.js
 @@ -514,12 +514,12 @@ function Multiplier(a, b, digitsA, digitsB, deciA, deciB) { var x = -maxNumDigits; var y = -digitsB.length * digitsA.length; graph.label([x, y + 2], - \$.ngettext("\\text{The top number has 1 digit to the right of the decimal.}", "\\text{The top number has %s digits to the right of the decimal.}", deciA), "right"); + "\\text{The top number has " + KhanUtil.plural(deciA, "digit") + " to the right of the decimal.}", "right"); graph.label([x, y + 1], - \$.ngettext("\\text{The bottom number has 1 digit to the right of the decimal.}", "\\text{The bottom number has %s digits to the right of the decimal.}", deciB), "right"); - // TODO(jeresig): i18n: Should this be pluralized? + "\\text{The bottom number has " + KhanUtil.plural(deciB, "digit") + " to the right of the decimal.}", "right"); graph.label([x, y], - \$._("\\text{The product has %s + %s = %s digits to the right of the decimal.}", deciA, deciB, deciA + deciB), "right"); + "\\text{The product has " + deciA + " + " + deciB + " = " + (deciA + deciB) + + " digits to the right of the decimal.}", "right"); graph.style({ fill: "#000" }, function() { @@ -597,9 +597,11 @@ function Divider(divisor, dividend, deciDivisor, deciDividend) { highlights = highlights.concat(drawDigits(totalDigits, index - totalDigits.length + 1, -2 * index, KhanUtil.BLUE)); graph.label([digitsDividend.length + 0.5, -2 * index], - \$._("\\text{How many times does }%s" + - "\\text{ go into }\\color{#6495ED}{%s}\\text{?}", - divisor, total), "right"); + "\\text{How many times does }" + + divisor + + "\\text{ go into }" + + "\\color{#6495ED}{" + total + "}" + + "\\text{?}", "right"); fShowFirstHalf = false; } else { @@ -629,8 +631,7 @@ function Divider(divisor, dividend, deciDivisor, deciDividend) { + "\\div" + divisor + "=" + "\\color{#28AE7B}{" + quotient + "}" - // TODO(jeresig): i18n: Should this be the whole expression? - + \$._("\\text{ or }") + + "\\text{ or }" + divisor + "\\times" + "\\color{#28AE7B}{" + quotient + "}" @@ -650,8 +651,7 @@ function Divider(divisor, dividend, deciDivisor, deciDividend) { this.addDecimal(); this.show(); graph.label([digitsDividend.length, 1], - \$._("\\text{Write in a decimal and a zero and continue dividing.}"), - "right"); + "\\text{Write in a decimal and a zero and continue dividing.}", "right"); }; this.getNumHints = function() { @@ -680,20 +680,17 @@ function Divider(divisor, dividend, deciDivisor, deciDividend) { if (deciDivisor !== 0) { graph.label([digitsDividend.length + 1 + (deciDiff > 0 ? deciDiff : 0), 1], - \$.ngettext("\\text{Shift the decimal %s to the right.}", - "\\text{Shift the decimal %s to the right.}", - deciDivisor), "right"); + "\\text{Shift the decimal " + deciDivisor + " to the right.}", "right"); graph.style({ fill: "#000" }, function() { graph.ellipse([-1, -0.2], [0.08, 0.04]); }); } else { - // TODO(jeresig): i18n: This probably won't work in multiple langs graph.label([digitsDividend.length + 0.5, 1.2], - \$._("\\text{Bring the decimal up into the}"), "right"); + "\\text{Bring the decimal up into the}", "right"); graph.label([digitsDividend.length + 0.5, 0.8], - \$._("\\text{answer (the quotient).}"), "right"); + "\\text{answer (the quotient).}", "right"); } this.addDecimal();
2  utils/hints.js
 @@ -26,7 +26,7 @@ \$(Khan).bind("newProblem", function() { \$("#hint") .removeClass("green") .addClass("orange") - .val(\$._("I'd like a hint")) + .val("I'd like a hint") .data("buttonText", false) .stop(true /* clear */, true /* jump */) .appendTo("#get-hint-button-container");
36 utils/i18n.js
 @@ -1,36 +0,0 @@ -/** - * Simple i18n method with sprintf-like %s replacement - */ -jQuery._ = function(str) { - var replaces = Array.prototype.slice.call(arguments, 1); - var obj = replaces[0] || {}; - - str = str.replace(/%s/g, function(all) { - var retVal = replaces.shift(); - return retVal === undefined ? all : retVal; - }); - - return str.replace(/%\(([\w_]+)\)s/g, function(all, name) { - var retVal = obj[name]; - return retVal === undefined ? all : retVal; - }); -}; - -jQuery.ngettext = function(single, plural, num) { - var replaces = Array.prototype.slice.call(arguments, 2); - var obj = replaces[1] || {}; - - // TODO(jeresig): i18n: Replace this with real i18n logic, likely from Jed - var str = num === 1 ? single : plural; - - str = str.replace(/%s/g, function(all) { - var retVal = replaces.shift(); - return retVal === undefined ? all : retVal; - }); - - return str.replace(/%\(([\w_]+)\)s/g, function(all, name) { - var retVal = obj[name] || num; - return retVal === undefined ? all : retVal; - }); -}; -
31 utils/math-format.js
 @@ -234,23 +234,9 @@ \$.extend(KhanUtil, { // Ported from https://github.com/clojure/clojure/blob/master/src/clj/clojure/pprint/cl_format.clj#L285 cardinal: function(n) { - // TODO(jeresig): i18n: Is this something that can be ported? - var cardinalScales = ["", \$._("thousand"), \$._("million"), - \$._("billion"), \$._("trillion"), \$._("quadrillion"), - \$._("quintillion"), \$._("sextillion"), \$._("septillion"), - \$._("octillion"), \$._("nonillion"), \$._("decillion"), - \$._("undecillion"), \$._("duodecillion"), \$._("tredecillion"), - \$._("quattuordecillion"), \$._("quindecillion"), - \$._("sexdecillion"), \$._("septendecillion"), \$._("octodecillion"), - \$._("novemdecillion"), \$._("vigintillion")]; - var cardinalUnits = [\$._("zero"), \$._("one"), \$._("two"), \$._("three"), - \$._("four"), \$._("five"), \$._("six"), \$._("seven"), \$._("eight"), - \$._("nine"), \$._("ten"), \$._("eleven"), \$._("twelve"), - \$._("thirteen"), \$._("fourteen"), \$._("fifteen"), \$._("sixteen"), - \$._("seventeen"), \$._("eighteen"), \$._("nineteen")]; - var cardinalTens = ["", "", \$._("twenty"), \$._("thirty"), \$._("forty"), - \$._("fifty"), \$._("sixty"), \$._("seventy"), \$._("eighty"), - \$._("ninety")]; + var cardinalScales = ["", "thousand", "million", "billion", "trillion", "quadrillion", "quintillion", "sextillion", "septillion", "octillion", "nonillion", "decillion", "undecillion", "duodecillion", "tredecillion", "quattuordecillion", "quindecillion", "sexdecillion", "septendecillion", "octodecillion", "novemdecillion", "vigintillion"]; + var cardinalUnits = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]; + var cardinalTens = ["", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]; // For formatting numbers less than 1000 var smallNumberWords = function(n) { var hundredDigit = Math.floor(n / 100); @@ -258,11 +244,9 @@ \$.extend(KhanUtil, { var str = ""; if (hundredDigit) { - str += \$.ngettext("%s hundred", "%s hundred", - cardinalUnits[hundredDigit]); + str += cardinalUnits[hundredDigit] + " hundred"; } - // TODO(jeresig): i18n: This will need to changed if (hundredDigit && rest) { str += " "; } @@ -278,7 +262,6 @@ \$.extend(KhanUtil, { str += cardinalTens[tenDigit]; } - // TODO(jeresig): i18n: This will need to changed if (tenDigit && unitDigit) { str += "-"; } @@ -293,7 +276,7 @@ \$.extend(KhanUtil, { }; if (n === 0) { - return \$._("zero"); + return "zero"; } else { var neg = false; if (n < 0) { @@ -319,10 +302,9 @@ \$.extend(KhanUtil, { } if (neg) { - words.unshift(\$._("negative")); + words.unshift("negative"); } - // TODO(jeresig): i18n: This will need to changed return words.join(" "); } }, @@ -472,7 +454,6 @@ \$.extend(KhanUtil, { }, randVar: function() { - // NOTE(jeresig): i18n: I assume it's OK to have roman letters here return KhanUtil.randFromArray(["x", "k", "y", "a", "n", "r", "p", "u", "v"]); },
7 utils/math.js
 @@ -58,11 +58,8 @@ \$.extend(KhanUtil, { return digits; }, - // TODO(jeresig): i18n: Does this make sense? - placesLeftOfDecimal: [\$._("one"), \$._("ten"), \$._("hundred"), - \$._("thousand")], - placesRightOfDecimal: [\$._("one"), \$._("tenth"), \$._("hundredth"), - \$._("thousandth")], + placesLeftOfDecimal: ["one", "ten", "hundred", "thousand"], + placesRightOfDecimal: ["one", "tenth", "hundredth", "thousandth"], powerToPlace: function(power) { if (power < 0) {
6 utils/mean-and-median.js
 @@ -14,8 +14,7 @@ \$.extend(KhanUtil, { ); graph.graph.meanLabel.remove(); - graph.graph.meanLabel = graph.label([mean, 1.3], \$._("\\text{mean}"), - "above", { color: KhanUtil.BLUE }); + graph.graph.meanLabel = graph.label([mean, 1.3], "\\text{mean}", "above", { color: KhanUtil.BLUE }); graph.graph.mean = mean; }, @@ -33,8 +32,7 @@ \$.extend(KhanUtil, { ); graph.graph.medianLabel.remove(); - graph.graph.medianLabel = graph.label([median, -1.7], - \$._("\\text{median}"), "below", { color: KhanUtil.GREEN }); + graph.graph.medianLabel = graph.label([median, -1.7], "\\text{median}", "below", { color: KhanUtil.GREEN }); graph.graph.median = median; },
10 utils/polynomials.js
 @@ -360,14 +360,14 @@ \$.extend(KhanUtil, { var composedFuncWithVal = composed.name + "(" + val + ")"; - hints.push(\$._("

To solve for the value of %s, " + - "we need to solve for the value of %s.

", - this.name, composedFuncWithVal)); + hints.push("

To solve for the value of " + this.name + "," + + "we need to solve for the value of " + + composedFuncWithVal + ".

"); hints = hints.concat(composed.hint(val)); - hints.push(\$._("

That means %s(%s) = %s

", - this.name, val, this.hintEvalOf(val, true))); + hints.push("

That means " + this.name + "(" + val + ") = " + + this.hintEvalOf(val, true) + "

"); hints.push("

" + this.name + "(" + val + ") = " + this.evalOf(val) + "

");
7 utils/probability.js
 @@ -1,7 +1,6 @@ \$.extend(KhanUtil, { /* coinFlips(2) returns * [["HH", 2], ["HT", 1], ["TH", 1], ["TT", 0]] */ - // TODO(jeresig): i18n: Does this make sense for i18n? coinFlips: function(n) { if (n === 0) { return [["", 0]]; @@ -11,15 +10,13 @@ \$.extend(KhanUtil, { var andAHead = \$.map(preceding, function(_arg, i) { var seq = _arg[0]; var h = _arg[1]; - // I18N: Represents "heads" on a coin - return [[\$._("H") + seq, h + 1]]; + return [["H" + seq, h + 1]]; }); var andATail = \$.map(preceding, function(_arg, i) { var seq = _arg[0]; var h = _arg[1]; - // I18N: Represents "tails" on a coin - return [[\$._("T") + seq, h]]; + return [["T" + seq, h]]; }); return andAHead.concat(andATail);
4 utils/qhints.js
57 utils/simplify.js
 @@ -17,8 +17,7 @@ } else { prodExpr = KhanUtil.moveSameOpsUp({op: "*", args: newArgs}); } - var subSteps = new KhanUtil.StepsProblem([], prodExpr, - \$._("simplify"), true); + var subSteps = new KhanUtil.StepsProblem([], prodExpr, "simplify", true); options.mergeCstFactors = false; prodExpr = simplify(prodExpr, options, subSteps); options.mergeCstFactors = true; @@ -28,8 +27,7 @@ var cstFactor1 = {op: "*", args: [splitExpr1.numExpr, splitExpr1.cstExpr]}; var cstFactor2 = {op: "*", args: [splitExpr2.numExpr, splitExpr2.cstExpr]}; var sumFactors = {op: "+", args: [cstFactor1, cstFactor2]}; - var subSteps = new KhanUtil.StepsProblem([], sumFactors, - \$._("simplify"), true); + var subSteps = new KhanUtil.StepsProblem([], sumFactors, "simplify", true); var cstFactor = simplify(sumFactors, options, subSteps); //steps.add(subSteps); return {op: "*", args: [cstFactor, splitExpr1.varExpr]}; @@ -64,8 +62,7 @@ }; var simplifySingleArg = function(expr, options, steps) { - var subSteps = new KhanUtil.StepsProblem([0], expr.args[0], - \$._("simplify")); + var subSteps = new KhanUtil.StepsProblem([0], expr.args[0], "simplify"); var sArg = simplify(expr.args[0], options, subSteps); steps.add(subSteps); return KhanUtil.exprCopyMissingStyle(expr, {op: expr.op, args: [sArg]}); @@ -74,8 +71,7 @@ var simplifyEachArg = function(expr, options, steps) { var newExpr = KhanUtil.exprClone(expr); for (var iArg = 0; iArg < newExpr.args.length; iArg++) { - var subSteps = new KhanUtil.StepsProblem([iArg], newExpr.args[iArg], - \$._("simplify")); + var subSteps = new KhanUtil.StepsProblem([iArg], newExpr.args[iArg], "simplify"); var sArg = simplify(newExpr.args[iArg], options, subSteps); subSteps.endExpr = sArg; if (steps === undefined) { @@ -364,13 +360,11 @@ newExpr = {op: "*", args: newArgs}; } if (options.expandProducts) { - var subSteps1 = new KhanUtil.StepsProblem([], newExpr, - \$._("expandProduct"), true); + var subSteps1 = new KhanUtil.StepsProblem([], newExpr, "expandProduct", true); var expanded = expandProduct(newExpr, subSteps1); steps.add(subSteps1); if (expanded.op === "+") { - var subSteps2 = new KhanUtil.StepsProblem([], expanded, - \$._("simplify"), true); + var subSteps2 = new KhanUtil.StepsProblem([], expanded, "simplify", true); var sExpanded = simplify(expanded, options, subSteps2); steps.add(subSteps2); return sExpanded; @@ -409,8 +403,7 @@ var simplificationOps = { "+": function(expr, options, steps) { var sExpr1 = KhanUtil.moveSameOpsUp(expr); - var subSteps = new KhanUtil.StepsProblem([], sExpr1, - \$._("simplify")); + var subSteps = new KhanUtil.StepsProblem([], sExpr1, "simplify"); var sExpr = simplifyEachArg(sExpr1, options, steps); steps.add(sExpr); sExpr = KhanUtil.moveSameOpsUp(sExpr); @@ -496,10 +489,8 @@ newExpr = factoredExpr; } } else { - steps.add( - \$._("

The expression %s can be factored as %s

", - KhanUtil.exprToCode(expr), - KhanUtil.exprToCode(newExpr))); + steps.add("

The expression " + KhanUtil.exprToCode(expr) + " can be factored as " + + KhanUtil.exprToCode(newExpr) + "

"); } } expr = KhanUtil.exprCopyMissingStyle(expr, newExpr); @@ -512,8 +503,7 @@ if ((expr.args.length === 2) && (options.changeSubIntoPlusNeg)) { return {op: "+", args: [expr.args[0], {op: "-", args: [expr.args[1]]}]}; } - var subSteps = new KhanUtil.StepsProblem([], expr, - \$._("simplify")); + var subSteps = new KhanUtil.StepsProblem([], expr, "simplify"); var sExpr = simplifyEachArg(expr, options, steps); if (expr.args.length === 1) { var arg = sExpr.args[0]; @@ -537,23 +527,19 @@ "cdot": simplifyTimesOp, "times": simplifyTimesOp, "^": function(expr, options, steps) { - var subSteps1 = new KhanUtil.StepsProblem([0], expr.args[0], - \$._("simplify")); + var subSteps1 = new KhanUtil.StepsProblem([0], expr.args[0], "simplify"); var term = simplify(expr.args[0], options, subSteps1); steps.add(subSteps1); - var subSteps2 = new KhanUtil.StepsProblem([1], expr.args[1], - \$._("simplify")); + var subSteps2 = new KhanUtil.StepsProblem([1], expr.args[1], "simplify"); var pow = simplify(expr.args[1], options, subSteps2); steps.add(subSteps2); if (options.mergePowerOfPower) { while ((typeof term === "object") && (term.op === "^")) { var curPow = {op: "*", args: [pow, term.args[1]]}; - var subSteps3 = new KhanUtil.StepsProblem([], curPow, - \$._("simplify"), true); + var subSteps3 = new KhanUtil.StepsProblem([], curPow, "simplify", true); pow = simplify(curPow, options, subSteps3); steps.add(subSteps3); - var subSteps4 = new KhanUtil.StepsProblem([], term.args[0], - \$._("simplify"), true); + var subSteps4 = new KhanUtil.StepsProblem([], term.args[0], "simplify", true); term = simplify(term.args[0], options, subSteps4); steps.add(subSteps4); } @@ -590,16 +576,14 @@ var numer = sExpr.args[0]; var denom = sExpr.args[1]; sExpr = {op: "*", args: [numer, {op: "^", args: [denom, -1]}]}; - var subSteps = new KhanUtil.StepsProblem([], sExpr, - \$._("simplify")); + var subSteps = new KhanUtil.StepsProblem([], sExpr, "simplify"); sExpr = simplify(sExpr, options, subSteps); steps.add(subSteps); } return sExpr; }, "ln": function(expr, options, steps) { - var subSteps = new KhanUtil.StepsProblem([0], expr.args[0], - \$._("simplify")); + var subSteps = new KhanUtil.StepsProblem([0], expr.args[0], "simplify"); var term = simplify(expr.args[0], options, subSteps); steps.add(subSteps); if (options.cancelLnExp && (typeof term === "object") && (term.op === "^") && @@ -615,8 +599,7 @@ return expr; } options.derivTerm = expr.args[1]; - var subSteps = new KhanUtil.StepsProblem([], expr.args[0], - \$._("differentiate")); + var subSteps = new KhanUtil.StepsProblem([], expr.args[0], "differentiate"); expr = KhanUtil.differentiate(expr.args[0], options, subSteps); steps.add(subSteps); options.derivTerm = oldDerivTerm; @@ -774,7 +757,7 @@ var simplify = function(expr, options, steps) { if (steps === undefined) { - steps = new KhanUtil.StepsProblem([], expr, \$._("simplify")); + steps = new KhanUtil.StepsProblem([], expr, "simplify"); } if (options === undefined) { options = {}; @@ -790,7 +773,7 @@ expr.text = KhanUtil.exprToText(expr); if (!KhanUtil.exprIdentical(expr, steps.startExpr)) { - var subSteps = new KhanUtil.StepsProblem([], expr, \$._("simplify")); + var subSteps = new KhanUtil.StepsProblem([], expr, "simplify"); expr = KhanUtil.simplify(expr, options, subSteps); steps.add(subSteps); } @@ -801,7 +784,7 @@ }; var simplifyWithHints = function(expr) { - var steps = new KhanUtil.StepsProblem([], expr, \$._("simplify")); + var steps = new KhanUtil.StepsProblem([], expr, "simplify"); var simp = simplify(expr, {}, steps); var hints = KhanUtil.genHints(steps); return {result: simp, hints: hints};
96 utils/simplifying-expressions.js
 @@ -90,100 +90,55 @@ var exampleGroup = [KhanUtil.parse("#{\\dfrac{a^2}{a}} &= #{\\dfrac{#{a} \\cdot a}{#{a}}}", [KhanUtil.BLUE, KhanUtil.BLUE, {cancel: true}, {cancel: true}]), KhanUtil.parse("&= #{\\dfrac{a}{1}}", [KhanUtil.BLUE]), KhanUtil.parse("&= #{a}", [KhanUtil.BLUE])]; - steps.add( - \$._("

To simplify this type of expression, we need to " + - "look for factors that are shared by both the numerator and " + - "the denominator.

") + - \$._("

For each such factor, if it is present with the same " + - "exponent both at the numerator and the denominator, then we" + - " can remove that factor completely. If the exponent is " + - "different, then we remove the one with the lowest exponent," + - " and substract it from the one with the higher exponent.

") - ); - - var subHints = [ - \$._("

Why can we simplify an expression this way? " + - "Let's look at the detailed steps that we imply when we " + - "write %s :

", - KhanUtil.format(exampleExprStep)) + - \$._("

%s can be rewritten as %s

", - KhanUtil.format(exampleExprInit), KhanUtil.parseFormat( - "\\dfrac{3}{5} \\cdot #{\\dfrac{a^2}{a}} \\cdot b \\cdot \\dfrac{1}{c}", [KhanUtil.BLUE])) + - "

" + KhanUtil.formatGroup(exampleGroup) + "

" + - \$._("

So we get %s, or %s", - KhanUtil.parseFormat("\\dfrac{3}{5} \\cdot #{a} \\cdot b \\cdot \\dfrac{1}{c}", [KhanUtil.BLUE]), - KhanUtil.parseFormat("\\dfrac{3ab}{5c}")) - ]; - - steps.add( - \$._("

For example, if we had this expression: " + - "%s, we would see that the factor " + - "%s is present in both the numerator and the " + - "denominator.

", KhanUtil.format(exampleExprInit), - KhanUtil.format(aExpr)) + - \$._("

We would then simplify it like this: %s " + - "and obtain: %s %s

", - KhanUtil.format(exampleExprStep), - KhanUtil.format(exampleExprEnd), - KhanUtil.getSubHints("factoring", - \$._("Show explanation"), subHints)) + - \$._("

Can you apply this technique to this exercise?

To simplify this type of expression, we need to look for factors that are shared by both the numerator and the denominator.

For each such factor, if it is present with the same exponent both at the numerator and the denominator, then we can remove that factor completely. If the exponent is different, then we remove the one with the lowest exponent, and substract it from the one with the higher exponent.

"); + var subHints = ["

Why can we simplify an expression this way? Let's look at the detailed steps that we imply when we write " + KhanUtil.format(exampleExprStep) + " :

" + KhanUtil.format(exampleExprInit) + " can be rewritten as " + + KhanUtil.parseFormat("\\dfrac{3}{5} \\cdot #{\\dfrac{a^2}{a}} \\cdot b \\cdot \\dfrac{1}{c}", [KhanUtil.BLUE]) + "

" + + KhanUtil.formatGroup(exampleGroup) + "

So we get " + + KhanUtil.parseFormat("\\dfrac{3}{5} \\cdot #{a} \\cdot b \\cdot \\dfrac{1}{c}", [KhanUtil.BLUE]) + ", or " + + KhanUtil.parseFormat("\\dfrac{3ab}{5c}") + ""]; + steps.add("

For example, if we had this expression: " + KhanUtil.format(exampleExprInit) + ", we would see that the factor " + KhanUtil.format(aExpr) + " is present in both the numerator and the denominator.

We would then simplify it like this: " + KhanUtil.format(exampleExprStep) + " and obtain: " + KhanUtil.format(exampleExprEnd) + " " + KhanUtil.getSubHints("factoring", "Show explanation", subHints) + "

Can you apply this technique to this exercise?

"); }; var factorNumeratorDenominator = function(expr, options, steps) { var newArgs = []; var wasSimplified = false; for (var iArg = 0; iArg < 2; iArg++) { - var subSteps = new KhanUtil.StepsProblem([0], expr.args[iArg], - \$._("simplify by factoring")); + var subSteps = new KhanUtil.StepsProblem([0], expr.args[iArg], "simplify by factoring"); var newArg = KhanUtil.simplify(expr.args[iArg], options, subSteps); // Récupérer les indices var termName; if (iArg === 0) { - termName = \$._("numerator"); + termName = "numerator"; } else { - termName = \$._("denominator"); + termName = "denominator"; } if (KhanUtil.stepIsUsed(subSteps)) { if (!wasSimplified) { steps.add("

" + KhanUtil.exprToCode(expr) + "

We can see that the %s can be factored " + - "some more : %s

", - termName, KhanUtil.exprToCode(expr.args[iArg]))); + steps.add("

We can see that the " + termName + " can be factored some more : " + KhanUtil.exprToCode(expr.args[iArg]) + "

So the %s becomes : %s

", - termName, KhanUtil.exprToCode(newArg))); + steps.add("

So the " + termName + " becomes : " + KhanUtil.exprToCode(newArg) + "

"); wasSimplified = true; } newArgs.push(newArg); } var newExpr = {op: expr.op, args: newArgs}; if (wasSimplified) { - steps.add(\$._("

We obtain the following expression:

") + - "

" + KhanUtil.exprToCode(newExpr) + "

We obtain the following expression :

" + KhanUtil.exprToCode(newExpr)); } return newExpr; }; var solveSimplifyingExpressionsExercise = function(expr) { - var steps = new KhanUtil.StepsProblem([], expr, - \$._("simplify by factoring")); + var steps = new KhanUtil.StepsProblem([], expr, "simplify by factoring"); addInitialSteps(steps); - var subSteps = new KhanUtil.StepsProblem([], expr, - \$._("factor numerator and denominator")); + var subSteps = new KhanUtil.StepsProblem([], expr, "factor numerator and denominator"); var options = KhanUtil.simplifyOptions.factor; var newExpr = factorNumeratorDenominator(expr, options, subSteps); if (KhanUtil.stepIsUsed(subSteps)) { - steps.add( - \$._("The first step is to factor the numerator and " + - "denominator, if possible: %s

", - KhanUtil.getSubHints("factoring-num-denom", - \$._("Show explanation"), - [KhanUtil.genOneHint(subSteps)])) + - \$._("

We obtain: %s

", - KhanUtil.exprToCode(newExpr)) - ); + steps.add("The first step is to factor the numerator and denominator, if possible : " + + KhanUtil.getSubHints("factoring-num-denom", "Show explanation", [KhanUtil.genOneHint(subSteps)]) + "

" + + "

We obtain : " + KhanUtil.exprToCode(newExpr) + "

"); } var factors = []; var argsOccFactors = [[], []]; @@ -223,19 +178,10 @@ var hintExpr = getFractionFromOccFactors(factors, newOccFactors, argsOccFactors); if (KhanUtil.exprIdentical(newExpr, solExpr)) { - steps.add( - \$._("

There are no factors that can " + - "be simplified in this expression, so the answer is: " + - "%s

There are no factors that can be simplified in this expression, so the answer is: " + KhanUtil.format(solExpr) + ""); } else { - steps.add( - \$._("

Applying the approach described above gives " + - "in this case:

") + - "

" + KhanUtil.format(hintExpr) + "

We obtain the following " + - "expression:

") + - "

" + KhanUtil.format(solExpr) + "

Applying the approach described above gives in this case:

" + KhanUtil.format(hintExpr) + "

We obtain the following expression:

" + KhanUtil.format(solExpr) + "

"); } var hints = KhanUtil.genHints(steps); return {solution: solExpr, hints: hints, choices: choices};
9 utils/steps-helpers.js
 @@ -37,16 +37,14 @@ //id = id + "-" + KhanUtil.random(); var html = "" + @@ -161,8 +159,7 @@ \$.each(path, function(node) { strPath += node + ", "; }); - // NOTE(jeresig): Why is this a JavaScript expression? - steps.add("putStepsInContext(" + KhanUtil.exprToCode(parentExpr) + ", [" + strPath + "])"); + steps.add("putStepsInContect(" + KhanUtil.exprToCode(parentExpr) + ", [" + strPath + "])"); }; var putStepsInContext = function(parentExpr, path, steps) {
4 utils/tmpl.js
 @@ -119,8 +119,8 @@ \$.tmpl = { youtubeIds = youtubeIds.split(/,\s*/); var author = \$(elem).data("video-hint-author") || "Sal"; - var msg = \$._("Watch %s work through a very similar problem:", - author); + var msg = "Watch " + author + + " work through a very similar problem:"; var preface = \$("

").text(msg); var wrapper = \$("

", { "class": "video-hint" });
3  utils/triangle-congruence.js
 @@ -542,8 +542,7 @@ \$.extend(KhanUtil, { }; }; - \$(".question").prepend(""); + \$(".question").prepend(""); \$("button#reflect").bind("click", function(event) { this.blur(); if (!triangle.animating) {
42 utils/visualizing-derivatives.js
 @@ -981,9 +981,7 @@ \$.extend(KhanUtil, { var self = this; _.each(this.problem.fnArray, function(fn, i) { - var nth = i > 0 ? - \$._("next") : - \$._("first"); + var nth = i > 0 ? "next" : "first"; fn = fn.derivative(); @@ -991,39 +989,32 @@ \$.extend(KhanUtil, { var inc; if (nCoefs === 1) { if (fn.coefs[0] === 0) { - inc = \$._("zero"); + inc = "zero"; } else if (fn.coefs[0] > 0) { - inc = \$._("constant and positive"); + inc = "constant and positive"; } else { - inc = \$._("constant and negative"); + inc = "constant and negative"; } } else if (nCoefs === 2) { + if (fn.coefs[1] > 0) { + inc = "increasing"; + } else { + inc = "decreasing"; + } var val = fn.evalOf(0) + fn.evalOf(self.INTERVAL_WIDTH); if (val >= 0) { - if (fn.coefs[1] > 0) { - inc = \$._("increasing and positive"); - } else { - inc = \$._("decreasing and positive"); - } + inc += " and positive"; } else { - if (fn.coefs[1] > 0) { - inc = \$._("increasing and negative"); - } else { - inc = \$._("decreasing and negative"); - } + inc += " and negative"; } } var hint; if (moveDeriv) { - hint = \$._("The %s section of the derivative is %s, " + - "so it corresponds to an original function whose " + - "slope is %s.", nth, inc, inc); + hint = "The " + nth + " section of the derivative is " + inc + ", so it corresponds to an original function whose slope is " + inc + "."; } else { - hint = \$._("The %s section of the antiderivative has a " + - "%s slope, so it corresponds to an original " + - "function that is %s.", nth, inc, inc); + hint = "The " + nth + " section of the antiderivative has a " + inc + " slope, so it corresponds to an original function that is " + inc + "."; } var hintproblem = self.problem.slice(i, i+1); @@ -1036,9 +1027,7 @@ \$.extend(KhanUtil, { var lastHint; if (this.noSolution) { - lastHint = \$._("Because these sections do not appear next " + - "to each other in the graph of f(x), " + - "there is no solution."); + lastHint = "Because these sections do not appear next to each other in the graph of f(x), there is no solution."; hints.push("

" + lastHint + "

"); hints.push("