Repository: darkskyapp/forecast-io-translations
Pull request #78 (2016-09-01 12:59:40)

Added Slovenian translations sl.json
Support for Slovenian Language


Patch:
diff --git a/lib/lang/sl.js b/lib/lang/sl.js
new file mode 100644
index 0000000..0886173
--- /dev/null
+++ b/lib/lang/sl.js
@@ -0,0 +1,143 @@
+function join_with_shared_prefix(a, b, joiner) {
+  var m = a,
+      i = 0,
+      j;
+
+  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": "brez padavin",
+  "mixed-precipitation": "možne padavine",
+  "possible-very-light-precipitation": "možne so rahle padavine",
+  "very-light-precipitation": "rahle padavine",
+  "possible-light-precipitation": "možne so rahle padavine",
+  "light-precipitation": "rahle padavine",
+  "medium-precipitation": "padavine",
+  "heavy-precipitation": "močne padavine",
+  "possible-very-light-rain": "možen je rahel dež",
+  "very-light-rain": "rosenje",
+  "possible-light-rain": "možen je rahel dež",
+  "light-rain": "rahel dež",
+  "medium-rain": "dež",
+  "heavy-rain": "močan dež",
+  "possible-very-light-sleet": "možnost rahlega žleda",
+  "very-light-sleet": "rahel žled",
+  "possible-light-sleet": "možnost žleda",
+  "light-sleet": "rahel žled",
+  "medium-sleet": "dež s snegom",
+  "heavy-sleet": "žled",
+  "possible-very-light-snow": "možno je rahlo sneženje",
+  "very-light-snow": "rahlo sneženje",
+  "possible-light-snow": "možnost rahlega sneženja",
+  "light-snow": "rahlo sneženje",
+  "medium-snow": "sneg",
+  "heavy-snow": "močno sneženje",
+  "light-wind": "vetrovno",
+  "medium-wind": "vetrovno",
+  "heavy-wind": "močni sunki vetra",
+  "low-humidity": "suho",
+  "high-humidity": "vlažno",
+  "fog": "megleno",
+  "light-clouds": "delno oblačno",
+  "medium-clouds": "pretežno oblačno",
+  "heavy-clouds": "oblačno",
+  "today-morning": "danes zjutraj",
+  "later-today-morning": "kasneje to jutro",
+  "today-afternoon": "danes popoldan",
+  "later-today-afternoon": "kasneje popoldan",
+  "today-evening": "zvečer",
+  "later-today-evening": "drevi",
+  "today-night": "danes zvečer",
+  "later-today-night": "danes zvečer",
+  "tomorrow-morning": "jutri zjutraj",
+  "tomorrow-afternoon": "jutri popoldne",
+  "tomorrow-evening": "jutri zvečer",
+  "tomorrow-night": "jutri zvečer",
+  "morning": "zjutraj",
+  "afternoon": "popoldan",
+  "evening": "zvečer",
+  "night": "zvečer",
+  "today": "danes",
+  "tomorrow": "jutri",
+  "sunday": "v nedeljo",
+  "monday": "v ponedeljek",
+  "tuesday": "v torek",
+  "wednesday": "v sredo",
+  "thursday": "v četrtek",
+  "friday": "v petek",
+  "saturday": "v soboto",
+  "minutes": "$1 min.",
+  "fahrenheit": "$1\u00B0F",
+  "celsius": "$1\u00B0C",
+  "inches": "$1 in.",
+  "centimeters": "$1 cm.",
+  "less-than": "manj kot $1",
+  "and": function(a, b) {
+    return join_with_shared_prefix(
+      a,
+      b,
+      a.indexOf(",") !== -1 ? ", in " : " in "
+    );
+  },
+  "through": function(a, b) {
+    return join_with_shared_prefix(a, b, " do ");
+  },
+  "with": "$1, s $2",
+  "range": "$1\u2013$2",
+  "parenthetical": "$1 ($2)",
+  "for-hour": "$1 za uro",
+  "starting-in": "$1 od $2",
+  "stopping-in": "$1 do $2",
+  "starting-then-stopping-later": "$1 od $2, do $3 kasneje",
+  "stopping-then-starting-later": "$1 do $2, začelo bo zopet $3 kasneje",
+  "for-day": "$1 čez dan",
+  "starting": "$1 od $2",
+  "until": function(condition, period) {
+    return condition + " do " + strip_prefix(period);
+  },
+  "until-starting-again": function(condition, a, b) {
+    return condition + " do " + strip_prefix(a) + ", začelo bo zopet " + b;
+  },
+  "starting-continuing-until": function(condition, a, b) {
+    return condition + " začel " + a + ", do " +
+           strip_prefix(b);
+  },
+  "during": "$1 $2",
+  "for-week": "$1 čez teden",
+  "over-weekend": "$1 v soboto in nedeljo",
+  "temperatures-peaking": "temperaturami do $1 $2",
+  "temperatures-rising": "temperaturami do $1 $2",
+  "temperatures-valleying": "najnižjimi temperaturamiokoli $1 $2",
+  "temperatures-falling": "temperaturami do $1 $2",
+  /* Capitalize the first letter of every word. */
+  "title": function(str) {
+    return str.charAt(0).toUpperCase() + str.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;
+  }
+});


Test patch:
diff --git a/test_cases/sl.json b/test_cases/sl.json
new file mode 100644
index 0000000..46768cf
--- /dev/null
+++ b/test_cases/sl.json
@@ -0,0 +1,248 @@
+{
+  "Jasno":
+    ["title", "clear"],
+
+  "Možne so rahle padavine":
+    ["title", "possible-very-light-precipitation"],
+	
+  "Rahle padavine":
+    ["title", "very-light-precipitation"],
+	
+  "Možne so rahle padavine":
+    ["title", "possible-light-precipitation"],
+	
+  "Rahle padavine":
+    ["title", "light-precipitation"],
+  
+  "Padavine":
+    ["title", "medium-precipitation"],
+
+  "Močne padavine":
+    ["title", "heavy-precipitation"],
+
+  "Možen je rahel dež":
+    ["title", "possible-very-light-rain"],
+
+  "Rosenje":
+    ["title", "very-light-rain"],
+
+  "Možen je rahel dež":
+    ["title", "possible-light-rain"],
+
+  "Rahel dež":
+    ["title", "light-rain"],
+
+  "Dež":
+    ["title", "medium-rain"],
+
+  "Močan dež":
+    ["title", "heavy-rain"],
+
+  "Možnost rahlega žleda":
+    ["title", "possible-very-light-sleet"],
+
+  "Rahel žled":
+    ["title", "very-light-sleet"],
+
+  "Možnost žleda":
+    ["title", "possible-light-sleet"],
+
+  "Rahel žled":
+    ["title", "light-sleet"],
+
+  "Dež s snegom":
+    ["title", "medium-sleet"],
+
+  "Žled":
+    ["title", "heavy-sleet"],
+
+  "Možno je rahlo sneženje":
+    ["title", "possible-very-light-snow"],
+
+  "Rahlo sneženje":
+    ["title", "very-light-snow"],
+
+  "Možnost rahlega sneženja":
+    ["title", "possible-light-snow"],
+
+  "Rahlo sneženje":
+    ["title", "light-snow"],
+
+  "Sneg":
+    ["title", "medium-snow"],
+
+  "Močno sneženje":
+    ["title", "heavy-snow"],
+
+  "Vetrovno":
+    ["title", "medium-wind"],
+
+  "Močni sunki vetra":
+    ["title", "heavy-wind"],
+
+  "Megleno":
+    ["title", "fog"],
+
+  "Pretežno oblačno":
+    ["title", "medium-clouds"],
+
+  "Oblačno":
+    ["title", "heavy-clouds"],
+	
+  "Suho in vetrovno":
+    ["title", ["and", "low-humidity", "light-wind"]],
+
+  "Rosenje in močni sunki vetra":
+    ["title", ["and", "very-light-rain", "heavy-wind"]],
+
+  "Vlažno in delno oblačno":
+    ["title", ["and", "high-humidity", "light-clouds"]],
+
+  "Jasno za uro.":
+    ["sentence", ["for-hour", "clear"]],
+
+  "Rahlo sneženje od 35 min.":
+    ["sentence", ["starting-in", "very-light-snow", ["minutes", 35]]],
+
+  "Rahel dež do 15 min.":
+    ["sentence", ["stopping-in", "light-rain", ["minutes", 15]]],
+
+  "Žled od 20 min., do 30 min. kasneje.":
+    ["sentence",
+      ["starting-then-stopping-later",
+        "heavy-sleet",
+        ["minutes", 20],
+        ["minutes", 30]]],
+
+  "Dež do 25 min., začelo bo zopet 8 min. kasneje.":
+    ["sentence",
+      ["stopping-then-starting-later",
+        "medium-rain",
+        ["minutes", 25],
+        ["minutes", 8]]],
+		
+  "Pretežno oblačno čez dan.":
+    ["sentence", ["for-day", "medium-clouds"]],
+
+  "Rahel žled od zjutraj.":
+    ["sentence", ["starting", "very-light-sleet", "morning"]],
+
+  "Močne padavine do popoldan.":
+    ["sentence", ["until", "heavy-precipitation", "afternoon"]],
+
+  "Vetrovno popoldan.":
+    ["sentence", ["during", "light-wind", "afternoon"]],
+
+  "Sneg drevi in jutri zjutraj.":
+    ["sentence", ["during",
+      "medium-snow",
+      ["and", "later-today-evening", "tomorrow-morning"]]],
+
+  "Močan dež do kasneje to jutro, začelo bo zopet zvečer.":
+    ["sentence", ["until-starting-again",
+      "heavy-rain",
+      "later-today-morning",
+      "today-evening"]],
+
+  "Oblačno začel zvečer, do zvečer.":
+    ["sentence", ["starting-continuing-until",
+      "heavy-clouds",
+      "evening",
+      "night"]],
+	  
+  "Rahel žled kasneje popoldan in megleno jutri zjutraj.":
+    ["sentence", ["and",
+      ["during", "light-sleet", "later-today-afternoon"],
+      ["during", "fog", "tomorrow-morning"]]],
+
+  "Močni sunki vetra začel danes zjutraj, do danes popoldan, in dež s snegom jutri zjutraj.":
+    ["sentence", ["and",
+      ["starting-continuing-until",
+        "heavy-wind",
+        "today-morning",
+        "today-afternoon"],
+      ["during", "medium-sleet", "tomorrow-morning"]]],
+
+  "Oblačno od danes zvečer in močno sneženje jutri popoldne.":
+    ["sentence", ["and",
+      ["starting", "heavy-clouds", "later-today-night"],
+      ["during", "heavy-snow", "tomorrow-afternoon"]]],
+
+  "Suho danes zvečer in rahle padavine začel jutri zvečer, do jutri zvečer.":
+    ["sentence", ["and",
+      ["during", "low-humidity", "today-night"],
+      ["starting-continuing-until",
+        "light-precipitation",
+        "tomorrow-evening",
+        "tomorrow-night"]]],
+
+  "Sneg (5 in.) zvečer.":
+    ["sentence", ["during",
+      ["parenthetical", "medium-snow", ["inches", 5]],
+      "night"]],
+
+  "Rahlo sneženje (2 cm.) kasneje to jutro.":
+    ["sentence", ["during",
+      ["parenthetical", "light-snow", ["centimeters", 2]],
+      "later-today-morning"]],
+
+  "Močno sneženje (8\u201312 in.) čez dan.":
+    ["sentence", ["for-day",
+      ["parenthetical", "heavy-snow", ["inches", ["range", 8, 12]]]]],
+
+  "Sneg (manj kot 1 cm.) popoldan.":
+    ["sentence", ["during",
+      ["parenthetical", "medium-snow", ["less-than", ["centimeters", 1]]],
+      "afternoon"]],
+
+
+  "Brez padavin čez teden, s temperaturami do 85\u00B0F jutri.":
+    ["sentence", ["with",
+      ["for-week", "no-precipitation"],
+      ["temperatures-peaking",
+        ["fahrenheit", 85],
+        "tomorrow"]]],
+
+  "Možne padavine v soboto in nedeljo, s temperaturami do 32\u00B0C v četrtek.":
+    ["sentence", ["with",
+      ["over-weekend", "mixed-precipitation"],
+      ["temperatures-rising",
+        ["celsius", 32],
+        "thursday"]]],
+
+  "Rosenje v ponedeljek, s najnižjimi temperaturamiokoli 15\u00B0F v petek.":
+    ["sentence", ["with",
+      ["during", "very-light-rain", "monday"],
+      ["temperatures-valleying",
+        ["fahrenheit", 15],
+        "friday"]]],
+
+  "Rahlo sneženje v torek in sredo, s temperaturami do 0\u00B0C v nedeljo.":
+    ["sentence", ["with",
+      ["during", "light-snow", ["and", "tuesday", "wednesday"]],
+      ["temperatures-falling",
+        ["celsius", 0],
+        "sunday"]]],
+
+  "Padavine danes do v soboto, s temperaturami do 100\u00B0F v ponedeljek.":
+    ["sentence", ["with",
+      ["during",
+        "medium-precipitation",
+        ["through", "today", "saturday"]],
+      ["temperatures-peaking",
+        ["fahrenheit", 100],
+        "monday"]]],
+
+  "Možne padavine (1\u20133 in.) čez dan.":
+    ["sentence",
+      ["for-day",
+        ["parenthetical", "mixed-precipitation", ["inches", ["range", 1, 3]]]]],
+
+  "Močno sneženje (1\u20133 in.)":
+    ["title", ["parenthetical", "heavy-snow", ["inches", ["range", 1, 3]]]],
+
+  "Močno sneženje (3\u20135 cm.)":
+    ["title", ["parenthetical", "heavy-snow", ["centimeters", ["range", 3, 5]]]]
+
+
+}