From d3a2a92ca93a820bcef6de12d3d1d24c53bf8a7a Mon Sep 17 00:00:00 2001 From: Chris Mitchell Date: Mon, 6 Jan 2020 19:11:58 +0000 Subject: [PATCH 01/18] Create gd.js (#234) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Create gd.js Create Gàidhlig (Scottish Gaelic) translation * Update gd.js * Update gd.js * Update gd.js * Update gd.js * Create gd.json test case * Update gd.js * Corrections in gd.json * Corrections in gd.js * Correct title case in gd.json * Corrections in gd.json * Corrections in gd.js * Corrections in gd.json * Corrections in gd.js * Corrections in gd.json * Corrections in gd.js * Corrections in gd.json * Corrections in gd.json * Update gd.js * Update gd.json * Update gd.js * Update gd.js * Update gd.js * Update gd.js * Update gd.js * Update gd.json * Update gd.json * Update gd.json * Removed extra space --- lib/lang/gd.js | 147 +++++++++++++++++++++++++++ test_cases/gd.json | 246 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 393 insertions(+) create mode 100644 lib/lang/gd.js create mode 100644 test_cases/gd.json diff --git a/lib/lang/gd.js b/lib/lang/gd.js new file mode 100644 index 00000000..4c2b0bc5 --- /dev/null +++ b/lib/lang/gd.js @@ -0,0 +1,147 @@ +"use strict"; + +function join_with_shared_prefix(a, b, joiner) { + let i = 0; + + while(i !== a.length && + i !== b.length && + a.charCodeAt(i) === b.charCodeAt(i)) + ++i; + + while(i && a.charCodeAt(i - 1) !== 32) + --i; + + return a + joiner + b.slice(i); +} + +module.exports = { + "clear": "soilleir", + "no-precipitation": "gun sileadh", + "mixed-precipitation": "sileadh measgaichte", + "possible-very-light-precipitation": "tha cothrom ann gum bi sileadh glè aotrom ann", + "very-light-precipitation": "sileadh glè aotrom", + "possible-light-precipitation": "tha cothrom ann gum bi sileadh aotrom ann", + "light-precipitation": "sileadh aotrom", + "medium-precipitation": "sileadh", + "heavy-precipitation": "sileadh trom", + "possible-very-light-rain": "tha cothrom ann gum bi uisge glè aotrom ann", + "very-light-rain": "uisge glè aotrom", + "possible-light-rain": "tha cothrom ann gum bi uisge aotrom ann", + "light-rain": "uisge aotrom", + "medium-rain": "uisge", + "heavy-rain": "uisge trom", + "possible-very-light-sleet": "tha cothrom ann gum bi flin glè aotrom ann", + "very-light-sleet": "flin glè aotrom", + "possible-light-sleet": "tha cothrom ann gum bi flin aotrom ann", + "light-sleet": "flin aotrom", + "medium-sleet": "flin", + "heavy-sleet": "flin trom", + "possible-very-light-snow": "tha cothrom ann gum bi fras sneachda ann", + "very-light-snow": "frasan sneachda", + "possible-light-snow": "tha cothrom ann gum bi sneachd aotrom ann", + "light-snow": "sneachd aotrom", + "medium-snow": "sneachd", + "heavy-snow": "sneachda trom", + "possible-thunderstorm": "tha cothrom ann gum bi stoirmean tàirneanaich ann", + "thunderstorm": "stoirmean tàirneanaich", + "light-wind": "oiteag shocair", + "medium-wind": "gaoth", + "heavy-wind": "gaoth chunnartach", + "low-humidity": "tioram", + "high-humidity": "tais", + "fog": "ceòthach", + "light-clouds": "sgothan aotrom", + "medium-clouds": "sgothach", + "heavy-clouds": "sgothan trom", + "today-morning": "madainn an-diugh", + "later-today-morning": "nas anmoiche madainn an-diugh", + "today-afternoon": "feasgar an-diugh", + "later-today-afternoon": "nas anmoiche feasgar an-diugh", + "today-evening": "feasgar an-diugh", + "later-today-evening": "nas anmoiche feasgar an-diugh", + "today-night": "a-nochd", + "later-today-night": "nas anmoiche a-nochd", + "tomorrow-morning": "madainn a-màireach", + "tomorrow-afternoon": "feasgar a-màireach", + "tomorrow-evening": "feasgar a-màireach", + "tomorrow-night": "an ath oidhche", + "morning": "anns a' mhadainn", + "afternoon": "anns an fheasgar", + "evening": "anns an fheasgar", + "night": "a-nochd", + "today": "an-diugh", + "tomorrow": "a-màireach", + "sunday": "Didòmhnaich", + "monday": "Diluain", + "tuesday": "Dimàirt", + "wednesday": "Diciadain", + "thursday": "Diardaoin", + "friday": "Dihaoine", + "saturday": "Disathairne", + "next-sunday": "Didòmhnaich an ath sheachdain", + "next-monday": "Diluain an ath sheachdain", + "next-tuesday": "Dimàirt an ath sheachdain", + "next-wednesday": "Diciadain an ath sheachdain", + "next-thursday": "Diardaoin an ath sheachdain", + "next-friday": "Dihaoine an ath sheachdain", + "next-saturday": "Disathairne an ath sheachdain", + "minutes": "$1 mion.", + "fahrenheit": "$1\u00B0F", + "celsius": "$1\u00B0C", + "inches": "$1 òir.", + "centimeters": "$1 cm.", + "less-than": "< $1", + "and": function(a, b) { + return join_with_shared_prefix( + a, + b, + a.indexOf(",") !== -1 ? ", agus " : " agus " + ); + }, + "through": function(a, b) { + return join_with_shared_prefix(a, b, " tro "); + }, + "with": "$1, le $2", + "range": "$1\u2013$2", + "parenthetical": "$1 ($2)", + "for-hour": "$1 fad uair a thìde", + "starting-in": "$1 a' tòiseachadh ann an $2", + "stopping-in": "$1 a' stad ann an $2", + "starting-then-stopping-later": "$1 a' tòiseachadh ann an $2, a' stad as dèidh $3", + "stopping-then-starting-later": "$1 a' stad ann an $2, a' tòiseachadh a-rithist as dèidh $3", + "for-day": "$1 fad an latha", + "starting": "$1 a' tòiseachadh $2", + "until": "$1 a' stad $2", + "until-starting-again": "$1 a' stad $2, a' tòiseachadh a-rithist $3", + "starting-continuing-until": "$1 a' tòiseachadh $2, a' stad $3", + "during": "$1 $2", + "for-week": "$1 fad na seachdain", + "over-weekend": "$1 thairis air an deireadh-sheachdain", + "temperatures-peaking": "an teòthachd as àirde a' ruigsinn $1 $2", + "temperatures-rising": "an teòthachd as àirde a' ruigsinn $1 $2", + "temperatures-valleying": "an teòthachd as àirde a' tuiteam gu $1 $2", + "temperatures-falling": "an teòthachd as àirde a' tuiteam gu $1 $2", + // Capitalize the first letter of every word, except if that word is + // "and". (This is a very crude bastardization of proper English titling + // rules, but it is adequate for the purposes of this module.) + "title": function(str) { + return str.replace(/\S+/g, function(word) { + return word === "Agus" ? + word : + word.charAt(0).toUpperCase() + word.slice(1); + }); + }, + /* Capitalize the first word of the sentence and end with a period. */ + "sentence": function(str) { + /* Capitalize. */ + str = str.charAt(0).toUpperCase() + str.slice(1); + + /* Add a period if there isn't already one. */ + if(str.charAt(str.length - 1) !== ".") + str += "."; + + return str; + }, + "unavailable-radar": "Cha deach dad a lorg an-dràsta air sgàth 's $1.", + "station-offline": "gu bheil a h-uile stèisean-radar far loidhne", +}; diff --git a/test_cases/gd.json b/test_cases/gd.json new file mode 100644 index 00000000..e3cd216e --- /dev/null +++ b/test_cases/gd.json @@ -0,0 +1,246 @@ +{ + "Soilleir": + ["title", "clear"], + + "Tha Cothrom Ann Gum Bi Sileadh Glè Aotrom Ann": + ["title", "possible-very-light-precipitation"], + + "Sileadh Glè Aotrom": + ["title", "very-light-precipitation"], + + "Tha Cothrom Ann Gum Bi Sileadh Aotrom Ann": + ["title", "possible-light-precipitation"], + + "Sileadh Aotrom": + ["title", "light-precipitation"], + + "Sileadh": + ["title", "medium-precipitation"], + + "Sileadh Trom": + ["title", "heavy-precipitation"], + + "Tha Cothrom Ann Gum Bi Uisge Glè Aotrom Ann": + ["title", "possible-very-light-rain"], + + "Uisge Glè Aotrom": + ["title", "very-light-rain"], + + "Tha Cothrom Ann Gum Bi Uisge Aotrom Ann": + ["title", "possible-light-rain"], + + "Uisge Aotrom": + ["title", "light-rain"], + + "Uisge": + ["title", "medium-rain"], + + "Uisge Trom": + ["title", "heavy-rain"], + + "Tha Cothrom Ann Gum Bi Flin Glè Aotrom Ann": + ["title", "possible-very-light-sleet"], + + "Flin Glè Aotrom": + ["title", "very-light-sleet"], + + "Tha Cothrom Ann Gum Bi Flin Aotrom Ann": + ["title", "possible-light-sleet"], + + "Flin Aotrom": + ["title", "light-sleet"], + + "Flin": + ["title", "medium-sleet"], + + "Flin Trom": + ["title", "heavy-sleet"], + + "Tha Cothrom Ann Gum Bi Fras Sneachda Ann": + ["title", "possible-very-light-snow"], + + "Frasan Sneachda": + ["title", "very-light-snow"], + + "Tha Cothrom Ann Gum Bi Sneachd Aotrom Ann": + ["title", "possible-light-snow"], + + "Sneachd Aotrom": + ["title", "light-snow"], + + "Sneachd": + ["title", "medium-snow"], + + "Sneachda Trom": + ["title", "heavy-snow"], + + "Gaoth": + ["title", "medium-wind"], + + "Gaoth Chunnartach": + ["title", "heavy-wind"], + + "Ceòthach": + ["title", "fog"], + + "Sgothach": + ["title", "medium-clouds"], + + "Sgothan Trom": + ["title", "heavy-clouds"], + + "Tioram Agus Oiteag Shocair": + ["title", ["and", "low-humidity", "light-wind"]], + + "Uisge Glè Aotrom Agus Gaoth Chunnartach": + ["title", ["and", "very-light-rain", "heavy-wind"]], + + "Tais Agus Sgothan Aotrom": + ["title", ["and", "high-humidity", "light-clouds"]], + + + "Soilleir fad uair a thìde.": + ["sentence", ["for-hour", "clear"]], + + "Frasan sneachda a' tòiseachadh ann an 35 mion.": + ["sentence", ["starting-in", "very-light-snow", ["minutes", 35]]], + + "Uisge aotrom a' stad ann an 15 mion.": + ["sentence", ["stopping-in", "light-rain", ["minutes", 15]]], + + "Flin trom a' tòiseachadh ann an 20 mion., a' stad as dèidh 30 mion.": + ["sentence", + ["starting-then-stopping-later", + "heavy-sleet", + ["minutes", 20], + ["minutes", 30]]], + + "Uisge a' stad ann an 25 mion., a' tòiseachadh a-rithist as dèidh 8 mion.": + ["sentence", + ["stopping-then-starting-later", + "medium-rain", + ["minutes", 25], + ["minutes", 8]]], + + + "Sgothach fad an latha.": + ["sentence", ["for-day", "medium-clouds"]], + + "Flin glè aotrom a' tòiseachadh anns a' mhadainn.": + ["sentence", ["starting", "very-light-sleet", "morning"]], + + "Gaoth a' stad a-nochd.": + ["sentence", ["until", "medium-wind", "today-night"]], + + "Sileadh trom a' stad anns an fheasgar.": + ["sentence", ["until", "heavy-precipitation", "afternoon"]], + + "Oiteag shocair anns an fheasgar.": + ["sentence", ["during", "light-wind", "afternoon"]], + + "Sneachd nas anmoiche feasgar an-diugh agus madainn a-màireach.": + ["sentence", ["during", + "medium-snow", + ["and", "later-today-evening", "tomorrow-morning"]]], + + "Uisge trom a' stad nas anmoiche madainn an-diugh, a' tòiseachadh a-rithist feasgar an-diugh.": + ["sentence", ["until-starting-again", + "heavy-rain", + "later-today-morning", + "today-evening"]], + + "Sgothan trom a' tòiseachadh anns an fheasgar, a' stad a-nochd.": + ["sentence", ["starting-continuing-until", + "heavy-clouds", + "evening", + "night"]], + + "Flin aotrom nas anmoiche feasgar an-diugh agus ceòthach madainn a-màireach.": + ["sentence", ["and", + ["during", "light-sleet", "later-today-afternoon"], + ["during", "fog", "tomorrow-morning"]]], + + "Gaoth chunnartach a' tòiseachadh madainn an-diugh, a' stad feasgar an-diugh, agus flin madainn a-màireach.": + ["sentence", ["and", + ["starting-continuing-until", + "heavy-wind", + "today-morning", + "today-afternoon"], + ["during", "medium-sleet", "tomorrow-morning"]]], + + "Sgothan trom a' tòiseachadh nas anmoiche a-nochd agus sneachda trom feasgar a-màireach.": + ["sentence", ["and", + ["starting", "heavy-clouds", "later-today-night"], + ["during", "heavy-snow", "tomorrow-afternoon"]]], + + "Tioram a-nochd agus sileadh aotrom a' tòiseachadh feasgar a-màireach, a' stad an ath oidhche.": + ["sentence", ["and", + ["during", "low-humidity", "today-night"], + ["starting-continuing-until", + "light-precipitation", + "tomorrow-evening", + "tomorrow-night"]]], + + "Sneachd (5 òir.) a-nochd.": + ["sentence", ["during", + ["parenthetical", "medium-snow", ["inches", 5]], + "night"]], + + "Sneachd aotrom (2 cm.) nas anmoiche madainn an-diugh.": + ["sentence", ["during", + ["parenthetical", "light-snow", ["centimeters", 2]], + "later-today-morning"]], + + "Sneachda trom (8\u201312 òir.) fad an latha.": + ["sentence", ["for-day", + ["parenthetical", "heavy-snow", ["inches", ["range", 8, 12]]]]], + + "Sneachd (< 1 cm.) anns an fheasgar.": + ["sentence", ["during", + ["parenthetical", "medium-snow", ["less-than", ["centimeters", 1]]], + "afternoon"]], + + + "Gun sileadh fad na seachdain, le an teòthachd as àirde a' ruigsinn 85\u00B0F a-màireach.": + ["sentence", ["with", + ["for-week", "no-precipitation"], + ["temperatures-peaking", + ["fahrenheit", 85], + "tomorrow"]]], + + "Sileadh measgaichte thairis air an deireadh-sheachdain, le an teòthachd as àirde a' ruigsinn 32\u00B0C Diardaoin.": + ["sentence", ["with", + ["over-weekend", "mixed-precipitation"], + ["temperatures-rising", + ["celsius", 32], + "thursday"]]], + + "Uisge glè aotrom Diluain, le an teòthachd as àirde a' tuiteam gu 15\u00B0F Dihaoine.": + ["sentence", ["with", + ["during", "very-light-rain", "monday"], + ["temperatures-valleying", + ["fahrenheit", 15], + "friday"]]], + + "Sneachd aotrom Dimàirt agus Diciadain an ath sheachdain, le an teòthachd as àirde a' tuiteam gu 0\u00B0C Didòmhnaich.": + ["sentence", ["with", + ["during", "light-snow", ["and", "tuesday", "next-wednesday"]], + ["temperatures-falling", + ["celsius", 0], + "sunday"]]], + + "Sileadh an-diugh tro Disathairne, le an teòthachd as àirde a' ruigsinn 100\u00B0F Diluain.": + ["sentence", ["with", + ["during", + "medium-precipitation", + ["through", "today", "saturday"]], + ["temperatures-peaking", + ["fahrenheit", 100], + "monday"]]], + + "Tha cothrom ann gum bi stoirmean tàirneanaich ann Diciadain an ath sheachdain agus Diardaoin an ath sheachdain.": + ["sentence", ["during", + "possible-thunderstorm", + ["and", "next-wednesday", "next-thursday"] + ]] +} From b6f8329230dd2581fe5eec506ffc29714de47be4 Mon Sep 17 00:00:00 2001 From: Jay LaPorte Date: Mon, 6 Jan 2020 14:13:39 -0500 Subject: [PATCH 02/18] v2.16.0: add Scottish Gaelic, thanks @MacMhicheil! --- package.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 0660f966..5937f467 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "translations", - "version": "2.15.1", + "version": "2.16.0", "description": "translate the Dark Sky API into any language", "author": { "name": "The Dark Sky Company", @@ -268,6 +268,10 @@ { "name": "Martin Macko", "web": "https://github.com/LinkedList" + }, + { + "name": "Chris Mitchell", + "web": "https://geidh.uk/" } ], "repository": { From 56559bd5875752029ebaca66ba28fee74219939d Mon Sep 17 00:00:00 2001 From: Antoniya Statelova Date: Wed, 8 Jan 2020 16:37:47 -0500 Subject: [PATCH 03/18] v3.0.0 Restructure STATUS sentences (breaking change) and add documentation for them (thank you @ironwallaby for doing this <3 ) --- README.md | 7 ++++++- lib/lang/bg.js | 8 ++++++-- lib/lang/en.js | 6 +++++- package.json | 2 +- test_cases/bg.json | 6 ++++-- test_cases/en.json | 6 +++++- 6 files changed, 27 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ad57b4ba..fd3a26d4 100644 --- a/README.md +++ b/README.md @@ -250,13 +250,18 @@ capitalized, and the sentence is to end with a period). For text summaries for the next hour (that is, `minutely.summary`), summaries of the following formats are produced: +* `["sentence", ["next-hour-forecast-status", PERSISTENCE, STATION_STATUS]]` * `["sentence", ["for-hour", WEATHER_CONDITION]]` * `["sentence", ["starting-in", PRECIPITATION_TYPE, DURATION]]` * `["sentence", ["stopping-in", PRECIPITATION_TYPE, DURATION]]` * `["sentence", ["starting-then-stopping-later", PRECIPITATION_TYPE, DURATION, DURATION]]` * `["sentence", ["stopping-then-starting-later", PRECIPITATION_TYPE, DURATION, DURATION]]` -Except for the first case, each such summary only takes precipitation into +The first case is an error case when nearby radar stations are experiencing issues +and describe the persistence of the problem as well as some information on the +stations' status. + +Except for the first two case, each such summary only takes precipitation into account, and tells how the intensity of precipitation will vary over the next hour or so. diff --git a/lib/lang/bg.js b/lib/lang/bg.js index 3a270ebe..aac6382d 100644 --- a/lib/lang/bg.js +++ b/lib/lang/bg.js @@ -167,6 +167,10 @@ module.exports = { return str; }, - "unavailable-radar": "Прогнозата за идния час временно не е на разположение поради $1.", - "station-offline": "липса на информация от всички близки станции", + "next-hour-forecast-status": "Прогнозата за идния час $1 поради $2.", + "temporarily-unavailable": "временно не е на разположение", + "partially-unavailable": "е частична", + "unavailable": "не е налична", + "station-offline": "това че всички близки станции не са на линия", + "station-incomplete": "пропуски в покритието от близки станции", }; diff --git a/lib/lang/en.js b/lib/lang/en.js index 58c5c770..0f5d136c 100644 --- a/lib/lang/en.js +++ b/lib/lang/en.js @@ -163,6 +163,10 @@ module.exports = { return str; }, - "unavailable-radar": "Next hour forecasts are temporarily unavailable due to $1.", + "next-hour-forecast-status": "Next hour forecasts are $1 due to $2.", + "temporarily-unavailable": "temporarily unavailable", + "partially-unavailable": "partially unavailable", + "unavailable": "unavailable", "station-offline": "all nearby radar stations being offline", + "station-incomplete": "gaps in coverage from nearby radar stations", }; diff --git a/package.json b/package.json index 5937f467..60590c27 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "translations", - "version": "2.16.0", + "version": "3.0.0", "description": "translate the Dark Sky API into any language", "author": { "name": "The Dark Sky Company", diff --git a/test_cases/bg.json b/test_cases/bg.json index 96a26f8d..ef66e31f 100644 --- a/test_cases/bg.json +++ b/test_cases/bg.json @@ -266,6 +266,8 @@ "Силен Дъжд и Гръмотевична Буря": ["title", ["and", "heavy-rain", "thunderstorm"]], - "Прогнозата за идния час временно не е на разположение поради липса на информация от всички близки станции.": - ["sentence",["unavailable-radar", "station-offline"]] + "Прогнозата за идния час временно не е на разположение поради това че всички близки станции не са на линия.": + ["sentence",["next-hour-forecast-status", "temporarily-unavailable", "station-offline"]], + "Прогнозата за идния час е частична поради пропуски в покритието от близки станции.": + ["sentence",["next-hour-forecast-status", "partially-unavailable", "station-incomplete"]] } diff --git a/test_cases/en.json b/test_cases/en.json index 7dfa2d94..725aabe7 100644 --- a/test_cases/en.json +++ b/test_cases/en.json @@ -260,5 +260,9 @@ ["starting-in", "very-light-rain", ["less-than", ["minutes", 1]]]], "Next hour forecasts are temporarily unavailable due to all nearby radar stations being offline.": - ["sentence",["unavailable-radar", "station-offline"]] + ["sentence",["next-hour-forecast-status", "temporarily-unavailable", "station-offline"]], + "Next hour forecasts are partially unavailable due to gaps in coverage from nearby radar stations.": + ["sentence",["next-hour-forecast-status", "partially-unavailable", "station-incomplete"]], + "Next hour forecasts are unavailable due to all nearby radar stations being offline.": + ["sentence",["next-hour-forecast-status", "unavailable", "station-offline"]] } From ad5e5def01df1649e2f1da4a14a88859e67c45ab Mon Sep 17 00:00:00 2001 From: Jay LaPorte Date: Wed, 8 Jan 2020 15:36:10 -0500 Subject: [PATCH 04/18] Update README.md --- README.md | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fd3a26d4..ab739f2f 100644 --- a/README.md +++ b/README.md @@ -226,6 +226,36 @@ Below is a listing of every possible machine-readable summary produced by Dark Sky. The listing is recursive so as to better describe how the various structural components interact. +### Status Information + +Instead of producing a summary of weather information, we may sometimes generate +a status message indicating an error of some sort. Such messages may take one of +the following forms: + +* `["sentence", [STATUS_MESSAGE, STATUS_TYPE, REASON]]` + +`STATUS_MESSAGE` may be one of the following: + +* `"next-hour-forecast-status"`: we have information to convey about our + hyperlocal next-hour forecasts + +`STATUS_TYPE` may be one of the following: + +* `"unavailable"`: no forecast is available for this request +* `"partially-unavailable"`: only a partial forecast is available for this request +* `"temporarily-unavailable"`: no forecast is available for this request, but we + expect it to be available again in the future + +`REASON` may be one of the following: + +* `"station-offline"`: we cannot generate a forecast because all nearby weather + stations are offline (e.g. for maintenance) +* `"station-incomplete"`: we cannot generate a forecast because of gaps in the + coverage of all nearby weather stations (e.g. radar beams are blocked by + local terrain) + +`"next-hour-forecast-status"`, `"unavailable"`, `"partially-unavailable"`, `"temporarily-unavailable"`, `"station-offline"`, and `"station-incomplete"` are not used in any other forms. + ### Moment Summaries When the API is producing a text summary for a single moment in time (that is, @@ -250,18 +280,13 @@ capitalized, and the sentence is to end with a period). For text summaries for the next hour (that is, `minutely.summary`), summaries of the following formats are produced: -* `["sentence", ["next-hour-forecast-status", PERSISTENCE, STATION_STATUS]]` * `["sentence", ["for-hour", WEATHER_CONDITION]]` * `["sentence", ["starting-in", PRECIPITATION_TYPE, DURATION]]` * `["sentence", ["stopping-in", PRECIPITATION_TYPE, DURATION]]` * `["sentence", ["starting-then-stopping-later", PRECIPITATION_TYPE, DURATION, DURATION]]` * `["sentence", ["stopping-then-starting-later", PRECIPITATION_TYPE, DURATION, DURATION]]` -The first case is an error case when nearby radar stations are experiencing issues -and describe the persistence of the problem as well as some information on the -stations' status. - -Except for the first two case, each such summary only takes precipitation into +Except for the first case, each such summary only takes precipitation into account, and tells how the intensity of precipitation will vary over the next hour or so. From 4bc7251c1d70e9bae1713c70ccd1d74c379f79ed Mon Sep 17 00:00:00 2001 From: Jay LaPorte Date: Wed, 8 Jan 2020 15:36:56 -0500 Subject: [PATCH 05/18] Update bg.js --- lib/lang/bg.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lang/bg.js b/lib/lang/bg.js index aac6382d..4a09fe76 100644 --- a/lib/lang/bg.js +++ b/lib/lang/bg.js @@ -168,9 +168,9 @@ module.exports = { return str; }, "next-hour-forecast-status": "Прогнозата за идния час $1 поради $2.", + "unavailable": "не е налична", "temporarily-unavailable": "временно не е на разположение", "partially-unavailable": "е частична", - "unavailable": "не е налична", "station-offline": "това че всички близки станции не са на линия", "station-incomplete": "пропуски в покритието от близки станции", }; From ef007d5ce3baca292037685fa3e5f8c05e26a144 Mon Sep 17 00:00:00 2001 From: Jay LaPorte Date: Wed, 8 Jan 2020 15:37:14 -0500 Subject: [PATCH 06/18] Update en.js --- lib/lang/en.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lang/en.js b/lib/lang/en.js index 0f5d136c..8914e4f7 100644 --- a/lib/lang/en.js +++ b/lib/lang/en.js @@ -164,9 +164,9 @@ module.exports = { return str; }, "next-hour-forecast-status": "Next hour forecasts are $1 due to $2.", + "unavailable": "unavailable", "temporarily-unavailable": "temporarily unavailable", "partially-unavailable": "partially unavailable", - "unavailable": "unavailable", "station-offline": "all nearby radar stations being offline", "station-incomplete": "gaps in coverage from nearby radar stations", }; From 9a7a58e8b8ccc9c881d0f7012895fe233112b238 Mon Sep 17 00:00:00 2001 From: Antoniya Statelova Date: Wed, 8 Jan 2020 16:48:52 -0500 Subject: [PATCH 07/18] v3.0.1 Make it WAY better than it was before - docs + slight reordering --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 60590c27..2e2e1429 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "translations", - "version": "3.0.0", + "version": "3.0.1", "description": "translate the Dark Sky API into any language", "author": { "name": "The Dark Sky Company", From c4a6355563371676140a4defa99cecf236d67743 Mon Sep 17 00:00:00 2001 From: Iwan Date: Thu, 9 Jan 2020 14:06:14 +0000 Subject: [PATCH 08/18] Add statuses and minor corrections (#286) --- lib/lang/cy.js | 16 +++++++++++++--- test_cases/cy.json | 19 ++++++++++++++++--- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/lib/lang/cy.js b/lib/lang/cy.js index fd467b8e..38fb42fb 100644 --- a/lib/lang/cy.js +++ b/lib/lang/cy.js @@ -48,7 +48,7 @@ module.exports = { "later-today-morning": "yn hwyrach bore yma", "today-afternoon": "y prynhawn yma", "later-today-afternoon": "yn hwyrach prynhawn yma", - "today-evening": "fin nos heno", + "today-evening": "gyda’r hwyr heno", "later-today-evening": "yn hwyrach fin nos heno", "today-night": "heno", "later-today-night": "yn hwyrach heno", @@ -58,7 +58,7 @@ module.exports = { "tomorrow-night": "nos yfory", "morning": "yn y bore", "afternoon": "yn y prynhawn", - "evening": "fin nos", + "evening": "gyda’r hwyr", "night": "dros nos", "today": "heddiw", "tomorrow": "yfory", @@ -89,8 +89,12 @@ module.exports = { return "llai na" + (/^(1|8|11|16)[\D\b]/.test(a) ? "g " : " ") + a; }, "and": function(a, b) { + // don't repeat 'yn y' + if (a.slice(0,5) === "yn y " && b.slice(0,5) === "yn y ") + return a + " a’r " + b.slice(5); // don't repeat 'ar' - if (a.slice(0,9) === "ar ddydd " && b.slice(0,9) === "ar ddydd ") b = b.slice(4); + if (a.slice(0,9) === "ar ddydd " && b.slice(0,9) === "ar ddydd ") + b = b.slice(4); return a // include comma if a list + (a.indexOf(",") !== -1 ? "," : "") @@ -141,4 +145,10 @@ module.exports = { str += "."; return str; }, + "next-hour-forecast-status": "Dydi rhagolygon yr awr nesa $1 oherwydd $2.", + "unavailable": "ddim ar gael", + "temporarily-unavailable": "ddim ar gael ar hyn o bryd", + "partially-unavailable": "ddim yn gyflawn", + "station-offline": "diffyg gwybodaeth o orsafoedd radar gerllaw", + "station-incomplete": "bylchau yn narpariaeth gorsafoedd radar gerllaw", }; diff --git a/test_cases/cy.json b/test_cases/cy.json index b14dcc84..f7bcff46 100644 --- a/test_cases/cy.json +++ b/test_cases/cy.json @@ -57,13 +57,13 @@ "medium-snow", ["and", "later-today-evening", "tomorrow-morning"]]], - "Glaw trwm hyd at hwyrach bore yma, gan gychwyn eto fin nos heno.": + "Glaw trwm hyd at hwyrach bore yma, gan gychwyn eto gyda’r hwyr heno.": ["sentence", ["until-starting-again", "heavy-rain", "later-today-morning", "today-evening"]], - "Cymylau trwchus yn cychwyn fin nos, gan barhau hyd at y nos.": + "Cymylau trwchus yn cychwyn gyda’r hwyr, gan barhau hyd at y nos.": ["sentence", ["starting-continuing-until", "heavy-clouds", "evening", @@ -158,5 +158,18 @@ ["through", "friday", "saturday"]], ["temperatures-peaking", ["fahrenheit", 100], - "monday"]]] + "monday"]]], + + "Glaw ysgafn yn bosib yn y bore a’r prynhawn.": + ["sentence", ["during", + "possible-light-rain", ["and", + "morning", "afternoon"]]], + + "Dydi rhagolygon yr awr nesa ddim ar gael ar hyn o bryd oherwydd diffyg gwybodaeth o orsafoedd radar gerllaw.": + ["sentence",["next-hour-forecast-status", "temporarily-unavailable", "station-offline"]], + "Dydi rhagolygon yr awr nesa ddim yn gyflawn oherwydd bylchau yn narpariaeth gorsafoedd radar gerllaw.": + ["sentence",["next-hour-forecast-status", "partially-unavailable", "station-incomplete"]], + "Dydi rhagolygon yr awr nesa ddim ar gael oherwydd diffyg gwybodaeth o orsafoedd radar gerllaw.": + ["sentence",["next-hour-forecast-status", "unavailable", "station-offline"]] + } From 1397af572b49cab74c83d4063827643a61d39410 Mon Sep 17 00:00:00 2001 From: Alexander Nilsen Date: Thu, 9 Jan 2020 15:07:35 +0100 Subject: [PATCH 09/18] =?UTF-8?q?Add=20support=20for=20Status=20Properties?= =?UTF-8?q?=20in=20Norwegian=20Bokm=C3=A5l=20(#287)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/lang/no.js | 6 ++++++ test_cases/no.json | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/lang/no.js b/lib/lang/no.js index 2596fb5a..c8ebcc58 100644 --- a/lib/lang/no.js +++ b/lib/lang/no.js @@ -152,4 +152,10 @@ module.exports = { return str; }, + "next-hour-forecast-status": "Værvarsel for neste time er $1 på grunn av $2.", + "unavailable": "ikke tilgjengelig", + "temporarily-unavailable": "midertidlig ikke tilgjengelig", + "partially-unavailable": "delvis ikke tilgjengelig", + "station-offline": "ingen kontakt med radarstasjoner i nærheten", + "station-incomplete": "hull i dekningen fra radarstasjoner i nærheten", }; diff --git a/test_cases/no.json b/test_cases/no.json index a1bd6088..00eff195 100644 --- a/test_cases/no.json +++ b/test_cases/no.json @@ -246,5 +246,12 @@ ["title", "possible-thunderstorm"], "Kraftige regnbyger og tordenvær": - ["title", ["and", "heavy-rain", "thunderstorm"]] + ["title", ["and", "heavy-rain", "thunderstorm"]], + + "Værvarsel for neste time er midertidlig ikke tilgjengelig på grunn av ingen kontakt med radarstasjoner i nærheten.": + ["sentence",["next-hour-forecast-status", "temporarily-unavailable", "station-offline"]], + "Værvarsel for neste time er delvis ikke tilgjengelig på grunn av hull i dekningen fra radarstasjoner i nærheten.": + ["sentence",["next-hour-forecast-status", "partially-unavailable", "station-incomplete"]], + "Værvarsel for neste time er ikke tilgjengelig på grunn av ingen kontakt med radarstasjoner i nærheten.": + ["sentence",["next-hour-forecast-status", "unavailable", "station-offline"]] } From fb850e0ce742e945cf053f2aaa805c62be1718bf Mon Sep 17 00:00:00 2001 From: ltressens Date: Thu, 9 Jan 2020 15:08:33 +0100 Subject: [PATCH 10/18] Add french translations for the STATUS sentences (#288) --- lib/lang/fr.js | 6 ++++++ test_cases/fr.json | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/lang/fr.js b/lib/lang/fr.js index de345d65..d67638f8 100644 --- a/lib/lang/fr.js +++ b/lib/lang/fr.js @@ -177,4 +177,10 @@ module.exports = { return str; }, + "next-hour-forecast-status": "Les prévisions pour la prochaine heure sont $1 car $2.", + "unavailable": "indisponibles", + "temporarily-unavailable": "temporairement indisponibles", + "partially-unavailable": "partiellement indisponibles", + "station-offline": "les stations radars voisines sont hors-ligne", + "station-incomplete": "il y a des lacunes dans la couverture des stations radars voisines", }; diff --git a/test_cases/fr.json b/test_cases/fr.json index 2e3a32a7..7a862103 100644 --- a/test_cases/fr.json +++ b/test_cases/fr.json @@ -242,5 +242,15 @@ ["sentence", ["during", "possible-thunderstorm", ["and", "next-wednesday", "next-thursday"] - ]] + ]], + + "Les prévisions pour la prochaine heure sont temporairement indisponibles car les stations radars voisines sont hors-ligne.": + ["sentence",["next-hour-forecast-status", "temporarily-unavailable", "station-offline"]], + + "Les prévisions pour la prochaine heure sont partiellement indisponibles car il y a des lacunes dans la couverture des stations radars voisines.": + ["sentence",["next-hour-forecast-status", "partially-unavailable", "station-incomplete"]], + + "Les prévisions pour la prochaine heure sont indisponibles car les stations radars voisines sont hors-ligne.": + ["sentence",["next-hour-forecast-status", "unavailable", "station-offline"]] + } From b9a82ecd98297d40688ab6bdf9ec71290ca3f38b Mon Sep 17 00:00:00 2001 From: Jay LaPorte Date: Thu, 9 Jan 2020 09:09:19 -0500 Subject: [PATCH 11/18] v3.0.2: add status messages in French, Norwegian, and Welsh --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2e2e1429..9bdf22c7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "translations", - "version": "3.0.1", + "version": "3.0.2", "description": "translate the Dark Sky API into any language", "author": { "name": "The Dark Sky Company", From 73a80df38ba4465f3a8fe85c7bc7a2dd196ca0a2 Mon Sep 17 00:00:00 2001 From: steronydh <4245329+steronydh@users.noreply.github.com> Date: Thu, 9 Jan 2020 21:22:51 +0000 Subject: [PATCH 12/18] Add status messages in Cornish (#290) * Cornish test cases updated * Offline radar station message added to Cornish * Cornish translation of offline radar stations * Add Status message in Cornish --- lib/lang/kw.js | 21 +++++++++++++-------- test_cases/kw.json | 9 ++++++++- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/lib/lang/kw.js b/lib/lang/kw.js index 5122c311..cbf7e25c 100644 --- a/lib/lang/kw.js +++ b/lib/lang/kw.js @@ -1,23 +1,23 @@ "use strict"; function in_the(period) { - if(period === "myttin" || period === "dohajydh" || period === "gorthugher" || period === "nos") { + if (period === "myttin" || period === "dohajydh" || period === "gorthugher" || period === "nos") { return " y'n " + period; } - if(period === "an dohajydh ma" || period === "an nos ma") { + if (period === "an dohajydh ma" || period === "an nos ma") { return " y'n " + period.slice(3); } - if("123456789".indexOf(period.charAt(0)) !== -1) { + if ("123456789".indexOf(period.charAt(0)) !== -1) { return " yn " + period; } return " " + period; } function until_the(period) { - if(period === "myttin" || period === "dohajydh" || period === "gorthugher" || period === "nos") { + if (period === "myttin" || period === "dohajydh" || period === "gorthugher" || period === "nos") { return " bys y'n " + period; } - if(period === "an dohajydh ma" || period === "an nos ma") { + if (period === "an dohajydh ma" || period === "an nos ma") { return " bys y'n " + period.slice(3); } return " bys yn " + period; @@ -102,7 +102,7 @@ module.exports = { "less-than": "le ages $1", "and": function(a, b) { let andy = a.indexOf(",") !== -1 ? ", ha" : " ha"; - if(b.charAt(0) === "a" || b.charAt(0) === "e" || b.charAt(0) === "i" || b.charAt(0) === "o" || b.charAt(0) === "u") { + if (b.charAt(0) === "a" || b.charAt(0) === "e" || b.charAt(0) === "i" || b.charAt(0) === "o" || b.charAt(0) === "u") { andy = andy + "g"; } @@ -144,7 +144,6 @@ module.exports = { }, "during": function(condition, period) { return condition + in_the(period); - // "$1 y\'n $2" }, "for-week": "$1 dres oll an seythun", "over-weekend": "$1 dres an bennseythun", @@ -169,9 +168,15 @@ module.exports = { str = str.charAt(0).toUpperCase() + str.slice(1); /* Add a period if there isn't already one. */ - if(str.charAt(str.length - 1) !== ".") + if (str.charAt(str.length - 1) !== ".") str += "."; return str; }, + "next-hour-forecast-status": "Darganow herwydh an our yw $1 drefen bos $2.", + "unavailable": "ankavadow", + "temporarily-unavailable": "ankavadow dres pols", + "partially-unavailable": "ankavadow yn rann", + "station-offline": "pub gorsav radar y'n ranndir dhywarlinen", + "station-incomplete": "aswaow y'n gorherans dhyworth gorsavow radar y'n ranndir", }; diff --git a/test_cases/kw.json b/test_cases/kw.json index ef4b8fc6..49682e1f 100644 --- a/test_cases/kw.json +++ b/test_cases/kw.json @@ -257,5 +257,12 @@ "Glaw pur skav ow talleth le ages 1 myn.": ["sentence", - ["starting-in", "very-light-rain", ["less-than", ["minutes", 1]]]] + ["starting-in", "very-light-rain", ["less-than", ["minutes", 1]]]], + + "Darganow herwydh an our yw ankavadow dres pols drefen bos pub gorsav radar y'n ranndir dhywarlinen.": + ["sentence",["next-hour-forecast-status", "temporarily-unavailable", "station-offline"]], + "Darganow herwydh an our yw ankavadow yn rann drefen bos aswaow y'n gorherans dhyworth gorsavow radar y'n ranndir.": + ["sentence",["next-hour-forecast-status", "partially-unavailable", "station-incomplete"]], + "Darganow herwydh an our yw ankavadow drefen bos pub gorsav radar y'n ranndir dhywarlinen.": + ["sentence",["next-hour-forecast-status", "unavailable", "station-offline"]] } From ff3aa9bbaf9f61537a333f94e3d9817332c4d2cc Mon Sep 17 00:00:00 2001 From: Jay LaPorte Date: Thu, 9 Jan 2020 16:23:25 -0500 Subject: [PATCH 13/18] v3.0.3: status messages in Cornish --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9bdf22c7..98d38a84 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "translations", - "version": "3.0.2", + "version": "3.0.3", "description": "translate the Dark Sky API into any language", "author": { "name": "The Dark Sky Company", From 9a339c6d2b9474d35d7c1bb5b7498fc98300c9b2 Mon Sep 17 00:00:00 2001 From: Martin Sefcik Date: Mon, 13 Jan 2020 15:23:05 +0100 Subject: [PATCH 14/18] Added slovak translations for the status sentences (#292) --- lib/lang/sk.js | 6 ++++++ test_cases/sk.json | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/lang/sk.js b/lib/lang/sk.js index c971eac1..f7e7ab73 100644 --- a/lib/lang/sk.js +++ b/lib/lang/sk.js @@ -236,4 +236,10 @@ module.exports = { return str; }, + "next-hour-forecast-status": "Predpoveď na ďalšiu hodinu je $1, pretože $2.", + "unavailable": "nedostupná", + "temporarily-unavailable": "dočasne nedostupná", + "partially-unavailable": "čiastočne nedostupná", + "station-offline": "všetky radarové stanice v okolí sú v režime offline", + "station-incomplete": "vznikli medzery v pokrytí radarovými stanicami v okolí", }; diff --git a/test_cases/sk.json b/test_cases/sk.json index b20c45b1..8a2d3be2 100644 --- a/test_cases/sk.json +++ b/test_cases/sk.json @@ -263,5 +263,12 @@ ["title", ["and", "heavy-rain", "thunderstorm"]], "Búrky až do budúceho pondelka.": - ["sentence", ["until", "thunderstorm", "next-monday"]] + ["sentence", ["until", "thunderstorm", "next-monday"]], + + "Predpoveď na ďalšiu hodinu je dočasne nedostupná, pretože všetky radarové stanice v okolí sú v režime offline.": + ["sentence",["next-hour-forecast-status", "temporarily-unavailable", "station-offline"]], + "Predpoveď na ďalšiu hodinu je čiastočne nedostupná, pretože vznikli medzery v pokrytí radarovými stanicami v okolí.": + ["sentence",["next-hour-forecast-status", "partially-unavailable", "station-incomplete"]], + "Predpoveď na ďalšiu hodinu je nedostupná, pretože všetky radarové stanice v okolí sú v režime offline.": + ["sentence",["next-hour-forecast-status", "unavailable", "station-offline"]] } From d6c3f0c2c7b650de245d050e8055016944e4ad15 Mon Sep 17 00:00:00 2001 From: Benjamin Blankenmeister Date: Mon, 13 Jan 2020 09:23:19 -0500 Subject: [PATCH 15/18] igpay_atinlay (#291) --- lib/lang/x-pig-latin.js | 6 ++++++ test_cases/x-pig-latin.json | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/lang/x-pig-latin.js b/lib/lang/x-pig-latin.js index 88e095a2..43cbb12b 100644 --- a/lib/lang/x-pig-latin.js +++ b/lib/lang/x-pig-latin.js @@ -168,4 +168,10 @@ module.exports = { return str; }, + "next-hour-forecast-status": "extnay hourway orecastsfay areway $1 ueday otay $2.", + "unavailable": "unavailableway", + "temporarily-unavailable": "emporarilytay unavailableway", + "partially-unavailable": "artiallypay unavailableway", + "station-offline": "allway earbynay adarray tationssay eingbay offlineway", + "station-incomplete": "apsgay inway overagecay romfay earbynay adarray ationsstay", }; diff --git a/test_cases/x-pig-latin.json b/test_cases/x-pig-latin.json index 45d03402..9558b330 100644 --- a/test_cases/x-pig-latin.json +++ b/test_cases/x-pig-latin.json @@ -242,5 +242,12 @@ ["title", "possible-thunderstorm"], "Eavyhay Ainray andway Understormsthay": - ["title", ["and", "heavy-rain", "thunderstorm"]] + ["title", ["and", "heavy-rain", "thunderstorm"]], + + "Extnay hourway orecastsfay areway emporarilytay unavailableway ueday otay allway earbynay adarray tationssay eingbay offlineway.": + ["sentence",["next-hour-forecast-status", "temporarily-unavailable", "station-offline"]], + "Extnay hourway orecastsfay areway artiallypay unavailableway ueday otay apsgay inway overagecay romfay earbynay adarray ationsstay.": + ["sentence",["next-hour-forecast-status", "partially-unavailable", "station-incomplete"]], + "Extnay hourway orecastsfay areway unavailableway ueday otay allway earbynay adarray tationssay eingbay offlineway.": + ["sentence",["next-hour-forecast-status", "unavailable", "station-offline"]] } From bb11a83b6701354b7ada03c5e0a6510ea2022d05 Mon Sep 17 00:00:00 2001 From: Jay LaPorte Date: Mon, 13 Jan 2020 09:23:52 -0500 Subject: [PATCH 16/18] v3.0.4: add Pig Latin and Slovak status messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 98d38a84..19d90cdb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "translations", - "version": "3.0.3", + "version": "3.0.4", "description": "translate the Dark Sky API into any language", "author": { "name": "The Dark Sky Company", From 254db17b405190ae99b9bb3533218e01b6c2b6c6 Mon Sep 17 00:00:00 2001 From: Jay LaPorte Date: Tue, 14 Jan 2020 13:59:04 -0500 Subject: [PATCH 17/18] Fix some minor issues in the English translations (#293) * fix up the English translations * clarify docs * tweak translation * minor tidyup --- README.md | 13 ++++--- lib/lang/en.js | 84 ++++++++++++++++++++++++++++++---------------- test_cases/en.json | 11 ++++-- 3 files changed, 73 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index ab739f2f..d70896aa 100644 --- a/README.md +++ b/README.md @@ -456,10 +456,15 @@ would be `["during", "rain", "next-wednesday"]`. * `RAIN_TYPE` * `SLEET_TYPE` * `SNOW_TYPE` -* `["parenthetical", SNOW_TYPE, SNOW_ACCUMULATION]`: For daily or weekly - summaries, if a significant amount of snow is expected, we will qualify it - with the amount of expected snow accumulation on the ground. (For example, - "snow (3-4 in.) throughout the day".) +* `["parenthetical", EXPECTED_PRECIP_TYPE, SNOW_ACCUMULATION]`: For daily or + weekly summaries, if a significant amount of snow is expected, we will + qualify it with the amount of expected snow accumulation. (For example, + "snow (3-4 in.) throughout the day".) PLEASE NOTE that it is possible for a + chance of snow accumulation to be forecasted even if the expected + precipitation type is rain or sleet: this may occur if the forecasted + temperature is right around the freezing point. Translations should clarify + that the parenthetical refers to a chance of snow in such circumstances. + (For example, "sleet (chance of 3-4 in. of snow) throughout the day".) In each of the below precipitation types, the intensity of precipitation is (very approximately) as follows: diff --git a/lib/lang/en.js b/lib/lang/en.js index 8914e4f7..9220f56a 100644 --- a/lib/lang/en.js +++ b/lib/lang/en.js @@ -6,26 +6,49 @@ function join_with_shared_prefix(a, b, joiner) { // HACK: This gets around "today through on Tuesday" or cases like it, which // are incorrect in English. - if(m === "today" || m === "tomorrow") + if(m === "today" || m === "tomorrow") { m = "on " + m; + } - while(i !== m.length && - i !== b.length && - m.charCodeAt(i) === b.charCodeAt(i)) + // Skip the prefix of b that is shared with a. + while( + i !== m.length && + i !== b.length && + m.charCodeAt(i) === b.charCodeAt(i) + ) { ++i; + } - while(i && m.charCodeAt(i - 1) !== 32) + // ...except whitespace! We need that whitespace! + while(i && b.charCodeAt(i - 1) !== 32) { --i; + } return a + joiner + b.slice(i); } function strip_prefix(period) { - return period.slice(0, 9) === "overnight" ? period.slice(4) : - period.slice(0, 7) === "in the " ? period.slice(7) : + return period.startsWith("overnight")? period.slice(4): + period.startsWith("in the ")? period.slice(7): period; } +function capitalize(str) { + // Do not capitalize articles, very short words, or units. + if( + str === "a" || + str === "and" || + str === "cm" || + str === "in" || + str === "of" || + str === "with" + ) { + return str; + } + + return str[0].toUpperCase() + str.slice(1); +} + module.exports = { "clear": "clear", "no-precipitation": "no precipitation", @@ -104,11 +127,7 @@ module.exports = { "centimeters": "$1 cm.", "less-than": "< $1", "and": function(a, b) { - return join_with_shared_prefix( - a, - b, - a.indexOf(",") !== -1 ? ", and " : " and " - ); + return join_with_shared_prefix(a, b, a.includes(",")? ", and ": " and "); }, "through": function(a, b) { return join_with_shared_prefix(a, b, " through "); @@ -116,7 +135,20 @@ module.exports = { "with": "$1, with $2", "range": "$1\u2013$2", "parenthetical": function(a, b) { - return a + " (" + b + (a === "mixed precipitation" ? " of snow)" : ")"); + // In the case of mixed precipitation, we want to clarify that the + // snow accumulation in the parenthetical is snow. In the case that it's + // of an unknown type or rain or sleet, we want to clarify that while snow + // isn't expected, it has a chance of occurring. The below checks do this. + + // HACK: These are not the best ways to determine the precipitation type... + if(!a.endsWith("flurries") && !a.endsWith("snow")) { + if(!a.startsWith("mixed")) { + b = "with a chance of " + b; + } + b += " of snow"; + } + + return a + " (" + b + ")"; }, "for-hour": "$1 for the hour", "starting-in": "$1 starting in $2", @@ -141,29 +173,25 @@ module.exports = { "temperatures-rising": "high temperatures rising to $1 $2", "temperatures-valleying": "high temperatures bottoming out at $1 $2", "temperatures-falling": "high temperatures falling to $1 $2", - // Capitalize the first letter of every word, except if that word is - // "and". (This is a very crude bastardization of proper English titling - // rules, but it is adequate for the purposes of this module.) + // Capitalize the first letter of every word except "and", "or", and units. + // (This is a very crude bastardization of proper English titling rules, but + // it is adequate for the purposes of this module.) "title": function(str) { - return str.replace( - /\b(?:a(?!nd\b)|c(?!m\.)|i(?!n\.)|[^\Waci])/g, - function(letter) { - return letter.toUpperCase(); - } - ); + return str.replace(/\w+/g, capitalize); }, - /* Capitalize the first word of the sentence and end with a period. */ + // Capitalize the first word of the sentence and end with a period. "sentence": function(str) { - /* Capitalize. */ - str = str.charAt(0).toUpperCase() + str.slice(1); + // Capitalize. + str = capitalize(str); - /* Add a period if there isn't already one. */ - if(str.charAt(str.length - 1) !== ".") + // Add a period if there isn't already one. + if(!str.endsWith(".")) { str += "."; + } return str; }, - "next-hour-forecast-status": "Next hour forecasts are $1 due to $2.", + "next-hour-forecast-status": "next hour forecasts are $1 due to $2", "unavailable": "unavailable", "temporarily-unavailable": "temporarily unavailable", "partially-unavailable": "partially unavailable", diff --git a/test_cases/en.json b/test_cases/en.json index 725aabe7..88474a0e 100644 --- a/test_cases/en.json +++ b/test_cases/en.json @@ -249,6 +249,9 @@ "Heavy Snow (3\u20135 cm.)": ["title", ["parenthetical", "heavy-snow", ["centimeters", ["range", 3, 5]]]], + "Rain (with a Chance of 2\u20134 in. of Snow)": + ["title", ["parenthetical", "medium-rain", ["inches", ["range", 2, 4]]]], + "Possible Thunderstorms": ["title", "possible-thunderstorm"], @@ -260,9 +263,11 @@ ["starting-in", "very-light-rain", ["less-than", ["minutes", 1]]]], "Next hour forecasts are temporarily unavailable due to all nearby radar stations being offline.": - ["sentence",["next-hour-forecast-status", "temporarily-unavailable", "station-offline"]], + ["sentence", ["next-hour-forecast-status", "temporarily-unavailable", "station-offline"]], + "Next hour forecasts are partially unavailable due to gaps in coverage from nearby radar stations.": - ["sentence",["next-hour-forecast-status", "partially-unavailable", "station-incomplete"]], + ["sentence", ["next-hour-forecast-status", "partially-unavailable", "station-incomplete"]], + "Next hour forecasts are unavailable due to all nearby radar stations being offline.": - ["sentence",["next-hour-forecast-status", "unavailable", "station-offline"]] + ["sentence", ["next-hour-forecast-status", "unavailable", "station-offline"]] } From feab83bed0634b4dd60398ec2ef0e4598723270f Mon Sep 17 00:00:00 2001 From: Jay LaPorte Date: Tue, 14 Jan 2020 13:59:30 -0500 Subject: [PATCH 18/18] v3.0.5: clean up English translation --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 19d90cdb..3e0c5640 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "translations", - "version": "3.0.4", + "version": "3.0.5", "description": "translate the Dark Sky API into any language", "author": { "name": "The Dark Sky Company",