Skip to content

Commit

Permalink
Merge pull request #1 from darkskyapp/master
Browse files Browse the repository at this point in the history
Update from darkskyapp/translations
  • Loading branch information
Chris Mitchell authored Jan 18, 2020
2 parents f4dfd88 + feab83b commit 57b456c
Show file tree
Hide file tree
Showing 18 changed files with 233 additions and 57 deletions.
43 changes: 39 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -426,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:
Expand Down
8 changes: 6 additions & 2 deletions lib/lang/bg.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ module.exports = {

return str;
},
"unavailable-radar": "Прогнозата за идния час временно не е на разположение поради $1.",
"station-offline": "липса на информация от всички близки станции",
"next-hour-forecast-status": "Прогнозата за идния час $1 поради $2.",
"unavailable": "не е налична",
"temporarily-unavailable": "временно не е на разположение",
"partially-unavailable": "е частична",
"station-offline": "това че всички близки станции не са на линия",
"station-incomplete": "пропуски в покритието от близки станции",
};
16 changes: 13 additions & 3 deletions lib/lang/cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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 ? "," : "")
Expand Down Expand Up @@ -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",
};
88 changes: 60 additions & 28 deletions lib/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -104,19 +127,28 @@ 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 ");
},
"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",
Expand All @@ -141,28 +173,28 @@ 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;
},
"unavailable-radar": "Next hour forecasts are temporarily unavailable due to $1.",
"next-hour-forecast-status": "next hour forecasts are $1 due to $2",
"unavailable": "unavailable",
"temporarily-unavailable": "temporarily unavailable",
"partially-unavailable": "partially unavailable",
"station-offline": "all nearby radar stations being offline",
"station-incomplete": "gaps in coverage from nearby radar stations",
};
6 changes: 6 additions & 0 deletions lib/lang/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
21 changes: 13 additions & 8 deletions lib/lang/kw.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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";
}

Expand Down Expand Up @@ -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",
Expand All @@ -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",
};
6 changes: 6 additions & 0 deletions lib/lang/no.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
6 changes: 6 additions & 0 deletions lib/lang/sk.js
Original file line number Diff line number Diff line change
Expand Up @@ -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í",
};
6 changes: 6 additions & 0 deletions lib/lang/x-pig-latin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "translations",
"version": "2.15.1",
"version": "3.0.5",
"description": "translate the Dark Sky API into any language",
"author": {
"name": "The Dark Sky Company",
Expand Down Expand Up @@ -268,6 +268,10 @@
{
"name": "Martin Macko",
"web": "https://github.com/LinkedList"
},
{
"name": "Chris Mitchell",
"web": "https://geidh.uk/"
}
],
"repository": {
Expand Down
6 changes: 4 additions & 2 deletions test_cases/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]]
}
Loading

0 comments on commit 57b456c

Please sign in to comment.