Repository: darkskyapp/forecast-io-translations
Pull request #36 (2015-06-24 21:16:21)

Add Slovak translation
Please add Slovak translation


Patch:
diff --git a/lib/lang/sk.js b/lib/lang/sk.js
new file mode 100644
index 0000000..c69cb90
--- /dev/null
+++ b/lib/lang/sk.js
@@ -0,0 +1,233 @@
+function endsWith(str, suffix) {
+  return str.indexOf(suffix, str.length - suffix.length) !== -1;
+}
+
+function remove_prefix_and_use_genitive(a) {
+  switch(a) {
+    case "dnes ráno":
+      return "dnešného rána";
+    case "dopoludnia":
+      return "dnešného dopoludnia";
+    case "dnes popoludní":
+      return "dnešného popoludnia";
+    case "dnes podvečer":
+      return "dnešného podvečera";
+    case "dnes večer":
+      return "dnešného večera";
+    case "dnes neskoro večer":
+      return "dnešného neskorého večera";
+    case "dnes v noci":
+      return "dnešnej noci";
+    case "dnes neskoro v noci":
+      return "dnešnej neskorej noci";
+    case "zajtra ráno":
+      return "zajtrajšieho rána";
+    case "zajtra popoludní":
+      return "zajtrajšieho popoludnia";
+    case "zajtra večer":
+      return "zajtrajšieho večera";
+    case "zajtra v noci":
+      return "zajtrajšej noci";
+    case "ráno":
+      return "rána";
+    case "popoludní":
+      return "popoludnia";
+    case "večer":
+      return "večera";
+    case "v noci":
+      return "noci";
+    case "v pondelok":
+      return "pondelka";
+    case "v utorok":
+      return "utorka";
+    case "v stredu":
+      return "stredy";
+    case "vo štvrtok":
+      return "štvrtka";
+    case "v piatok":
+      return "piatka";
+    case "v sobotu":
+      return "soboty";
+    case "v nedeľu":
+      return "nedele";
+    default:
+        return a;
+  } 
+}
+
+function join_with_shared_prefix(a, b, joiner) {
+  var m = a,
+      i = 0,
+      j;
+
+  /* HACK: This gets around "today through on Tuesday" or cases like it, which
+   * are incorrect in English. */
+  if(m === "today" || m === "tomorrow")
+    m = "on " + m;
+
+  while(i !== m.length &&
+        i !== b.length &&
+        m.charCodeAt(i) === b.charCodeAt(i))
+    ++i;
+
+  while(i && m.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) :
+                                              period;
+}
+
+module.exports = require("../template")({
+  "clear": "jasno",
+  "no-precipitation": "bez zrážok",
+  "mixed-precipitation": "zmiešané zrážky",
+  "possible-very-light-precipitation": "možnosť veľmi slabých zrážok",
+  "very-light-precipitation": "veľmi slabé zrážky",
+  "possible-light-precipitation": "možnosť slabých zrážok",
+  "light-precipitation": "slabé zrážky",
+  "medium-precipitation": "zrážky",
+  "heavy-precipitation": "silné zrážky",
+  "possible-very-light-rain": "možnosť mrholenia",
+  "very-light-rain": "mrholenie",
+  "possible-light-rain": "možnosť slabého dažďa",
+  "light-rain": "slabý dážď",
+  "medium-rain": "dážď",
+  "heavy-rain": "vydatný dážď",
+  "possible-very-light-sleet": "možnosť slabého dažďa so snehom",
+  "very-light-sleet": "slabý dážď so snehom",
+  "possible-light-sleet": "možnosť slabého dažďa so snehom",
+  "light-sleet": "slabý dážď so snehom",
+  "medium-sleet": "dážď so snehom",
+  "heavy-sleet": "vydatný dážď so snehom",
+  "possible-very-light-snow": "možnosť slabého sneženia",
+  "very-light-snow": "slabé sneženie",
+  "possible-light-snow": "možnosť slabého sneženia",
+  "light-snow": "slabé sneženie",
+  "medium-snow": "sneženie",
+  "heavy-snow": "vydatné sneženie",
+  "light-wind": "slabý vietor",
+  "medium-wind": "veterno",
+  "heavy-wind": "silný vietor",
+  "low-humidity": "nízka vlhkosť",
+  "high-humidity": "vysoká vlhkosť",
+  "fog": "hmlisto",
+  "light-clouds": "čiastočne zamračené",
+  "medium-clouds": "prevažne zamračené",
+  "heavy-clouds": "zamračené",
+  "today-morning": "dnes ráno",
+  "later-today-morning": "dopoludnia",
+  "today-afternoon": "dnes popoludní",
+  "later-today-afternoon": "dnes podvečer",
+  "today-evening": "dnes večer",
+  "later-today-evening": "dnes neskoro večer",
+  "today-night": "dnes v noci",
+  "later-today-night": "dnes neskoro v noci",
+  "tomorrow-morning": "zajtra ráno",
+  "tomorrow-afternoon": "zajtra popoludní",
+  "tomorrow-evening": "zajtra večer",
+  "tomorrow-night": "zajtra v noci",
+  "morning": "ráno",
+  "afternoon": "popoludní",
+  "evening": "večer",
+  "night": "v noci",
+  "today": "dnes",
+  "tomorrow": "zajtra",
+  "sunday": "v nedeľu",
+  "monday": "v pondelok",
+  "tuesday": "v utorok",
+  "wednesday": "v stredu",
+  "thursday": "vo štvrtok",
+  "friday": "v piatok",
+  "saturday": "v sobotu",
+  "minutes": "$1 min.",
+  "fahrenheit": "$1°F",
+  "celsius": "$1°C",
+  "inches": "$1 in",
+  "centimeters": "$1 cm",
+  "less-than": "menej ako $1",
+  "and": function(a, b) {
+    return join_with_shared_prefix(
+      a,
+      b,
+      " a "
+    );
+  },
+  "through": function(a, b) {
+    return "od " + remove_prefix_and_use_genitive(a) + " do " + remove_prefix_and_use_genitive(b);
+  },
+  "with": "$1, $2",
+  "range": "$1-$2",
+  "parenthetical": function(a, b) {
+    return a + " (" + b + (a === "zmiešané zrážky" ? " snehu)" : ")");
+  },
+  "for-hour": "$1 hodinu",
+  "starting-in": "$1 o $2",
+  "stopping-in": "$1 skončí o $2",
+  "starting-then-stopping-later": "$1 o $2, skončí o $3 neskôr",
+  "stopping-then-starting-later": "$1 skončí o $2 a začne znovu o $3 neskôr",
+  "for-day": "Počas dňa $1",
+  "starting": function(a, b) {
+    return "od " + remove_prefix_and_use_genitive(b) + " " + a;
+  },
+  "until": function(condition, period) {
+    return condition + " až do " + remove_prefix_and_use_genitive(period);
+  },
+  "until-starting-again": function(condition, a, b) {
+    var starting = "";
+    if(endsWith(condition, "zrážky"))
+      starting = ", ktoré začnú znovu ";
+    else if(endsWith(condition, "dážď") || endsWith(condition, "dážď so snehom") || endsWith(condition, "vietor"))
+      starting = ", ktorý začne znovu ";
+    else if(endsWith(condition, "sneženie") || endsWith(condition, "mrholenie"))
+      starting = ", ktoré začne znovu ";
+    else if(endsWith(condition, "vlhkosť"))
+      starting = ", ktorá začne znovu ";
+    else if(endsWith(condition, "zamračené") || endsWith(condition, "hmlisto"))
+      starting = "a začne znovu ";
+    
+    return condition + " až do " + remove_prefix_and_use_genitive(a) + starting + b;
+  },
+  "starting-continuing-until": function(condition, a, b) {
+    var continuing = "";
+    if(endsWith(condition, "zrážky"))
+      continuing = ", ktoré pretrvajú až do ";
+    else if(endsWith(condition, "dážď") || endsWith(condition, "dážď so snehom") || endsWith(condition, "vietor"))
+      continuing = ", ktorý pretrvá až do ";
+    else if(endsWith(condition, "sneženie") || endsWith(condition, "mrholenie"))
+      continuing = ", ktoré pretrvá až do ";
+    else if(endsWith(condition, "vlhkosť"))
+      continuing = ", ktorá pretrvá až do ";
+    else if(endsWith(condition, "zamračené") || endsWith(condition, "hmlisto"))
+      continuing = "a pretrvá až do ";
+    return "od " + remove_prefix_and_use_genitive(a) + " " + condition + continuing + remove_prefix_and_use_genitive(b);
+  },
+  "during": "$2 $1",
+  "for-week": "$1 počas týždňa",
+  "over-weekend": "$1 cez víkend",
+  "temperatures-peaking": "$2 s teplotným maximom $1",
+  "temperatures-rising": "$2 s teplotami stúpajúcimi k $1",
+  "temperatures-valleying": "$2 s teplotným minimom $1",
+  "temperatures-falling": "$2 s teplotami klesajúcimi k $1",
+  /* 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;
+  },
+  /* 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;
+  }
+});


Test patch:
diff --git a/test_cases/sk.json b/test_cases/sk.json
new file mode 100644
index 0000000..8163383
--- /dev/null
+++ b/test_cases/sk.json
@@ -0,0 +1,251 @@
+{
+  "jasno":
+    ["title", "clear"],
+
+  "možnosť veľmi slabých zrážok":
+    ["title", "possible-very-light-precipitation"],
+
+  "slabé zrážky":
+    ["title", "very-light-precipitation"],
+
+  "možnosť slabých zrážok":
+    ["title", "possible-light-precipitation"],
+
+  "slabé zrážky":
+    ["title", "light-precipitation"],
+
+  "zrážky":
+    ["title", "medium-precipitation"],
+
+  "silné zrážky":
+    ["title", "heavy-precipitation"],
+
+  "možnosť mrholenia":
+    ["title", "possible-very-light-rain"],
+
+  "mrholenie":
+    ["title", "very-light-rain"],
+
+  "možnosť slabého dažďa":
+    ["title", "possible-light-rain"],
+
+  "slabý dážď":
+    ["title", "light-rain"],
+
+  "dážď":
+    ["title", "medium-rain"],
+
+  "vydatný dážď":
+    ["title", "heavy-rain"],
+
+  "možnosť slabého dažďa so snehom":
+    ["title", "possible-very-light-sleet"],
+
+  "slabý dážď so snehom":
+    ["title", "very-light-sleet"],
+
+  "možnosť slabého dažďa so snehom":
+    ["title", "possible-light-sleet"],
+
+  "slabý dážď so snehom":
+    ["title", "light-sleet"],
+
+  "dážď so snehom":
+    ["title", "medium-sleet"],
+
+  "vydatný dážď so snehom":
+    ["title", "heavy-sleet"],
+
+  "možnosť slabého sneženia":
+    ["title", "possible-very-light-snow"],
+
+  "slabé sneženie":
+    ["title", "very-light-snow"],
+
+  "možnosť slabého sneženia":
+    ["title", "possible-light-snow"],
+
+  "slabé sneženie":
+    ["title", "light-snow"],
+
+  "sneženie":
+    ["title", "medium-snow"],
+
+  "vydatné sneženie":
+    ["title", "heavy-snow"],
+
+  "veterno":
+    ["title", "medium-wind"],
+
+  "silný vietor":
+    ["title", "heavy-wind"],
+
+  "hmlisto":
+    ["title", "fog"],
+
+  "prevažne zamračené":
+    ["title", "medium-clouds"],
+
+  "zamračené":
+    ["title", "heavy-clouds"],
+
+  "nízka vlhkosť a slabý vietor":
+    ["title", ["and", "low-humidity", "light-wind"]],
+
+  "mrholenie a silný vietor":
+    ["title", ["and", "very-light-rain", "heavy-wind"]],
+
+  "vysoká vlhkosť a čiastočne zamračené":
+    ["title", ["and", "high-humidity", "light-clouds"]],
+
+
+  "Jasno hodinu.":
+    ["sentence", ["for-hour", "clear"]],
+
+  "Slabé sneženie o 35 min.":
+    ["sentence", ["starting-in", "very-light-snow", ["minutes", 35]]],
+
+  "Slabý dážď skončí o 15 min.":
+    ["sentence", ["stopping-in", "light-rain", ["minutes", 15]]],
+
+  "Vydatný dážď so snehom o 20 min., skončí o 30 min. neskôr.":
+    ["sentence",
+      ["starting-then-stopping-later",
+        "heavy-sleet",
+        ["minutes", 20],
+        ["minutes", 30]]],
+
+  "Dážď skončí o 25 min. a začne znovu o 8 min. neskôr.":
+    ["sentence",
+      ["stopping-then-starting-later",
+        "medium-rain",
+        ["minutes", 25],
+        ["minutes", 8]]],
+
+
+  "Počas dňa prevažne zamračené.":
+    ["sentence", ["for-day", "medium-clouds"]],
+
+  "Od rána slabý dážď so snehom.":
+    ["sentence", ["starting", "very-light-sleet", "morning"]],
+
+  "Veterno až do dnešnej noci.":
+    ["sentence", ["until", "medium-wind", "today-night"]],
+
+  "Silné zrážky až do popoludnia.":
+    ["sentence", ["until", "heavy-precipitation", "afternoon"]],
+
+  "Popoludní slabý vietor.":
+    ["sentence", ["during", "light-wind", "afternoon"]],
+
+  "Dnes neskoro večer a zajtra ráno sneženie.":
+    ["sentence", ["during",
+      "medium-snow",
+      ["and", "later-today-evening", "tomorrow-morning"]]],
+
+  "Vydatný dážď až do dnešného dopoludnia, ktorý začne znovu dnes večer.":
+    ["sentence", ["until-starting-again",
+      "heavy-rain",
+      "later-today-morning",
+      "today-evening"]],
+
+  "Od dnešnej neskorej noci zamračené a zajtra popoludní vydatné sneženie.":
+    ["sentence", ["starting-continuing-until",
+      "heavy-clouds",
+      "evening",
+      "night"]],
+
+  "Dnes podvečer slabý dážď so snehom a zajtra ráno hmlisto.":
+    ["sentence", ["and",
+      ["during", "light-sleet", "later-today-afternoon"],
+      ["during", "fog", "tomorrow-morning"]]],
+
+  "Od dnešného rána silný vietor, ktorý pretrvá až do dnešného popoludnia a zajtra ráno dážď so snehom.":
+    ["sentence", ["and",
+      ["starting-continuing-until",
+        "heavy-wind",
+        "today-morning",
+        "today-afternoon"],
+      ["during", "medium-sleet", "tomorrow-morning"]]],
+
+  "Od dnešnej neskorej noci zamračené a zajtra popoludní vydatné sneženie.":
+    ["sentence", ["and",
+      ["starting", "heavy-clouds", "later-today-night"],
+      ["during", "heavy-snow", "tomorrow-afternoon"]]],
+
+  "Dnes v noci nízka vlhkosť a od zajtrajšieho večera slabé zrážky, ktoré pretrvajú až do zajtrajšej noci.":
+    ["sentence", ["and",
+      ["during", "low-humidity", "today-night"],
+      ["starting-continuing-until",
+        "light-precipitation",
+        "tomorrow-evening",
+        "tomorrow-night"]]],
+
+  "V noci sneženie (5 in).":
+    ["sentence", ["during",
+      ["parenthetical", "medium-snow", ["inches", 5]],
+      "night"]],
+
+  "Dopoludnia slabé sneženie (2 cm).":
+    ["sentence", ["during",
+      ["parenthetical", "light-snow", ["centimeters", 2]],
+      "later-today-morning"]],
+
+  "Počas dňa vydatné sneženie (8-12 in).":
+    ["sentence", ["for-day",
+      ["parenthetical", "heavy-snow", ["inches", ["range", 8, 12]]]]],
+
+  "Popoludní sneženie (menej ako 1 cm).":
+    ["sentence", ["during",
+      ["parenthetical", "medium-snow", ["less-than", ["centimeters", 1]]],
+      "afternoon"]],
+
+
+  "Bez zrážok počas týždňa, zajtra s teplotným maximom 85°F.":
+    ["sentence", ["with",
+      ["for-week", "no-precipitation"],
+      ["temperatures-peaking",
+        ["fahrenheit", 85],
+        "tomorrow"]]],
+
+  "Zmiešané zrážky cez víkend, vo štvrtok s teplotami stúpajúcimi k 32°C.":
+    ["sentence", ["with",
+      ["over-weekend", "mixed-precipitation"],
+      ["temperatures-rising",
+        ["celsius", 32],
+        "thursday"]]],
+
+  "V pondelok mrholenie, v piatok s teplotným minimom 15°F.":
+    ["sentence", ["with",
+      ["during", "very-light-rain", "monday"],
+      ["temperatures-valleying",
+        ["fahrenheit", 15],
+        "friday"]]],
+
+  "V utorok a stredu slabé sneženie, v nedeľu s teplotami klesajúcimi k 0°C.":
+    ["sentence", ["with",
+      ["during", "light-snow", ["and", "tuesday", "wednesday"]],
+      ["temperatures-falling",
+        ["celsius", 0],
+        "sunday"]]],
+
+  "Od dnes do soboty zrážky, v pondelok s teplotným maximom 100°F.":
+    ["sentence", ["with",
+      ["during",
+        "medium-precipitation",
+        ["through", "today", "saturday"]],
+      ["temperatures-peaking",
+        ["fahrenheit", 100],
+        "monday"]]],
+
+  "Počas dňa zmiešané zrážky (1-3 in snehu).":
+    ["sentence",
+      ["for-day",
+        ["parenthetical", "mixed-precipitation", ["inches", ["range", 1, 3]]]]],
+
+  "vydatné sneženie (1-3 in)":
+    ["title", ["parenthetical", "heavy-snow", ["inches", ["range", 1, 3]]]],
+
+  "vydatné sneženie (3-5 cm)":
+    ["title", ["parenthetical", "heavy-snow", ["centimeters", ["range", 3, 5]]]]
+}