From f2f4fbdce972baf53f714bcc7c9a6a9b006fcc03 Mon Sep 17 00:00:00 2001 From: Jason LaPorte Date: Fri, 26 Jul 2013 16:29:44 -0400 Subject: [PATCH] Figured I'd forget all about snow the moment it turns nice. --- README.md | 5 +++++ TODO | 7 ++++++- lib/lang/english.js | 5 +++++ test-cases/english.json | 10 +++++----- test.js | 2 +- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ca594752..1a76cb46 100644 --- a/README.md +++ b/README.md @@ -309,12 +309,17 @@ number of arguments.) * `"minutes"`/1 * `"fahrenheit"`/1 * `"celsius"`/1 +* `"inches"`/1 +* `"centimeters"`/1 #### Conjunctions * `"and"`/2 * `"through"`/2 * `"with"`/2 +* `"range"`/2 +* `"parenthetical"`/2 +* `"less-than"`/1 #### Clauses diff --git a/TODO b/TODO index cb86a505..e690490e 100644 --- a/TODO +++ b/TODO @@ -14,4 +14,9 @@ This would be a lot cleaner. --- -I think I neglected the case for snow accumulation! Oops. +I think I neglected the tests for snow accumulation! Oops. + + (parenthetical X (inches 2)) => "X (2 in.)" + (parenthetical X (centimeters 4)) => "X (4 cm.)" + (parenthetical X (inches (less-than 1))) => "X (under 1 in.)" + (parenthetical X (centimeters (range 6 10))) => "X (6-10 cm.)" diff --git a/lib/lang/english.js b/lib/lang/english.js index 8d583301..4a6dd35e 100644 --- a/lib/lang/english.js +++ b/lib/lang/english.js @@ -73,6 +73,9 @@ module.exports = require("../template")({ "minutes": "$1 min.", "fahrenheit": "$1\u00B0F", "celsius": "$1\u00B0C", + "inches": "$1 in.", + "centimeters": "$1 cm.", + "less-than": "under $1", "and": function(a, b) { return join_with_shared_prefix( a, @@ -84,6 +87,8 @@ module.exports = require("../template")({ return join_with_shared_prefix(a, b, " through "); }, "with": "$1, with $2", + "range": "$1\u2013$2", + "parenthetical": "$1 ($2)", "for-hour": "$1 for the hour", "starting-in": "$1 starting in $2", "stopping-in": "$1 stopping in $2", diff --git a/test-cases/english.json b/test-cases/english.json index 9242303b..8bb22580 100644 --- a/test-cases/english.json +++ b/test-cases/english.json @@ -90,35 +90,35 @@ "tomorrow-night"]]], - "No precipitation throughout the week, with temperatures peaking at 85°F tomorrow.": + "No precipitation throughout the week, with temperatures peaking at 85\u00B0F tomorrow.": ["sentence", ["with", ["for-week", "no-precipitation"], ["temperatures-peaking", ["fahrenheit", 85], "tomorrow"]]], - "Mixed precipitation over the weekend, with temperatures rising to 32°C on Thursday.": + "Mixed precipitation over the weekend, with temperatures rising to 32\u00B0C on Thursday.": ["sentence", ["with", ["over-weekend", "mixed-precipitation"], ["temperatures-rising", ["celsius", 32], "thursday"]]], - "Drizzle today, with temperatures bottoming out at 15°F on Friday.": + "Drizzle today, with temperatures bottoming out at 15\u00B0F on Friday.": ["sentence", ["with", ["during", "very-light-rain", "today"], ["temperatures-valleying", ["fahrenheit", 15], "friday"]]], - "Light snow on Monday and Tuesday, with temperatures falling to 0°C on Sunday.": + "Light snow on Monday and Tuesday, with temperatures falling to 0\u00B0C on Sunday.": ["sentence", ["with", ["during", "light-snow", ["and", "monday", "tuesday"]], ["temperatures-falling", ["celsius", 0], "sunday"]]], - "Precipitation on Wednesday through Saturday, with temperatures peaking at 100°F on Monday.": + "Precipitation on Wednesday through Saturday, with temperatures peaking at 100\u00B0F on Monday.": ["sentence", ["with", ["during", "medium-precipitation", diff --git a/test.js b/test.js index eeb0d46d..fc842f7d 100644 --- a/test.js +++ b/test.js @@ -74,7 +74,7 @@ describe("translation", function() { describe(name, function() { var cases = JSON.parse( - fs.readFileSync(path.join(__dirname, "test-cases", lang)) + fs.readFileSync(path.join(__dirname, "test-cases", lang), "utf8") ); Object.keys(cases).forEach(function(summary) {