Repository: darkskyapp/forecast-io-translations
Pull request #64 (2016-02-08 20:15:30)

Cornish language added
Cornish language translation and test suite added in kw.js and kw.json.


Patch:
diff --git a/lib/lang/kw.js b/lib/lang/kw.js
new file mode 100644
index 0000000..2e02b5e
--- /dev/null
+++ b/lib/lang/kw.js
@@ -0,0 +1,164 @@
+function in_the(period) {
+  var f=period.charAt(0);
+  var n="123456789";
+  if (period==="myttin" || period==="dohajydh" || period==="gorthugher" || period==="nos")
+    return " y\'n " + period;
+  else if (period==="an dohajydh ma" || period==="an nos ma")
+    return " y\'n " + period.slice(3);
+  else if (n.indexOf(f)!=-1)
+    return " yn " + period;
+  else
+    return " " + period;
+}
+
+function until_the(period) {
+  if (period==="myttin" || period==="dohajydh" || period==="gorthugher" || period==="nos")
+    return " bys y\'n " + period;
+  else if (period==="an dohajydh ma" || period==="an nos ma")
+      return " bys y\'n " + period.slice(3);
+  else
+    return " bys yn " + period;
+}
+
+module.exports = require("../template")({
+  "clear": "kler",
+  "no-precipitation": "kodhans vyth",
+  "mixed-precipitation": "kodhans kemyskys",
+  "possible-very-light-precipitation": "kodhans skav possybyl",
+  "very-light-precipitation": "kodhans pur skav",
+  "possible-light-precipitation": "kodhans skav possybyl",
+  "light-precipitation": "kodhans skav",
+  "medium-precipitation": "kodhans",
+  "heavy-precipitation": "kodhans poos",
+  "possible-very-light-rain": "glaw skav possybyl",
+  "very-light-rain": "glaw pur skav",
+  "possible-light-rain": "glaw skav possybyl",
+  "light-rain": "glaw skav",
+  "medium-rain": "glaw",
+  "heavy-rain": "glaw poos",
+  "possible-very-light-sleet": "erghlaw skav possybyl",
+  "very-light-sleet": "erghlaw pur skav",
+  "possible-light-sleet": "erghlaw skav possybyl",
+  "light-sleet": "erghlaw skav",
+  "medium-sleet": "erghlaw",
+  "heavy-sleet": "erghlaw poos",
+  "possible-very-light-snow": "ergh skav possybyl",
+  "very-light-snow": "ergh pur skav",
+  "possible-light-snow": "ergh skav possybyl",
+  "light-snow": "ergh skav",
+  "medium-snow": "ergh",
+  "heavy-snow": "ergh poos",
+  "light-wind": "nebes gwynsek",
+  "medium-wind": "gwynsek",
+  "heavy-wind": "gwynsek bys yn peryl",
+  "low-humidity": "sygh",
+  "high-humidity": "glyb",
+  "fog": "niwlek",
+  "light-clouds": "nebes komolek",
+  "medium-clouds": "komolek",
+  "heavy-clouds": "komolek poos",
+  "today-morning": "hedhyw vyttin",
+  "later-today-morning": "diwettha hedhyw vyttin",
+  "today-afternoon": "an dohajydh ma",
+  "later-today-afternoon": "diwettha an dohajydh ma",
+  "today-evening": "haneth",
+  "later-today-evening": "diwettha haneth",
+  "today-night": "an nos ma",
+  "later-today-night": "diwettha haneth",
+  "tomorrow-morning": "ternos vyttin",
+  "tomorrow-afternoon": "dohajydhweyth a-vorow",
+  "tomorrow-evening": "gorthugherweyth a-vorow",
+  "tomorrow-night": "nosweyth a-vorow",
+  "morning": "myttin",
+  "afternoon": "dohajydh",
+  "evening": "gorthugher",
+  "night": "nos",
+  "today": "hedhyw",
+  "tomorrow": "a-vorow",
+  "sunday": "dy' Sul",
+  "monday": "dy' Lun",
+  "tuesday": "dy' Meurth",
+  "wednesday": "dy' Mergher",
+  "thursday": "dy' Yow",
+  "friday": "dy' Gwener",
+  "saturday": "dy' Sadorn",
+  "minutes": "$1 myn.",
+  "fahrenheit": "$1\u00B0F",
+  "celsius": "$1\u00B0C",
+  "inches": "$1 mv.",
+  "centimeters": "$1 cm.",
+  "less-than": "le ages $1",
+  "and": function(a, b) {
+    var 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")
+      andy = andy + "g";
+
+    return a + andy + " " + b;
+  },
+  "through": function(a, b) {
+    return a + until_the(b);//" dres " + b;
+  },
+  "with": "$1, gans $2",
+  "range": "$1\u2013$2",
+  "parenthetical": function(a, b) {
+    return a + " (" + b + (a === "kodhans kemyskys" ? " a ergh)" : ")");
+  },
+  "for-hour": "$1 rag an our",
+  "starting-in": function(condition, period) {
+    return condition + " ow talleth" + in_the(period);
+  },
+  "stopping-in": function(condition, period) {
+    return condition + " ow hedhi" + in_the(period);
+  },
+  "starting-then-stopping-later": function(condition, period1, period2) {
+    return condition + " ow talleth" + in_the(period1) + ", ow hedhi "+period2+" diwettha";
+  },
+  "stopping-then-starting-later": function(condition, period1, period2) {
+    return condition + " ow hedhi" + in_the(period1) + ", ow tastalleth "+period2+" diwettha";
+  },
+  "for-day": "$1 dres oll an jydh",
+  "starting": function(condition, period) {
+    return condition + " ow talleth" + in_the(period);
+  },
+  "until": function(condition, period) {
+    return condition + until_the(period);
+  },
+  "until-starting-again": function(condition, a, b) {
+    return condition + until_the(a) + ", ow tastalleth " + b;
+  },
+  "starting-continuing-until": function(condition, a, b) {
+    return condition + " ow talleth" + in_the(a) + ", ow pesya" + until_the(b);
+  },
+  "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",
+  "temperatures-peaking": "ughella tempredhow a $1 $2",
+  "temperatures-rising": "tempredhow ow kressya dhe $1 $2",
+  "temperatures-valleying": "tempredhow ow hedhi kodha dhe $1 $2",
+  "temperatures-falling": "tempredhow ow kodha dhe $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(
+      /\b(?:a(?!nd\b)|c(?!m\.)|i(?!n\.)|[^\Waci])/g,
+      function(letter) {
+        return letter.toUpperCase();
+      }
+    );
+  },
+  /* 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/kw.json b/test_cases/kw.json
new file mode 100644
index 0000000..ef1db1e
--- /dev/null
+++ b/test_cases/kw.json
@@ -0,0 +1,251 @@
+{
+  "Kler":
+    ["title", "clear"],
+
+  "Kodhans Skav Possybyl":
+    ["title", "possible-very-light-precipitation"],
+
+  "Kodhans Skav":
+    ["title", "very-light-precipitation"],
+
+  "Kodhans Skav Possybyl":
+    ["title", "possible-light-precipitation"],
+
+  "Kodhans Skav":
+    ["title", "light-precipitation"],
+
+  "Kodhans":
+    ["title", "medium-precipitation"],
+
+  "Kodhans Poos":
+    ["title", "heavy-precipitation"],
+
+  "Glaw Skav Possybyl":
+    ["title", "possible-very-light-rain"],
+
+  "Glaw Pur Skav":
+    ["title", "very-light-rain"],
+
+  "Glaw Skav Possybyl":
+    ["title", "possible-light-rain"],
+
+  "Glaw Skav":
+    ["title", "light-rain"],
+
+  "Glaw":
+    ["title", "medium-rain"],
+
+  "Glaw Poos":
+    ["title", "heavy-rain"],
+
+  "Erghlaw Skav Possybyl":
+    ["title", "possible-very-light-sleet"],
+
+  "Erghlaw Pur Skav":
+    ["title", "very-light-sleet"],
+
+  "Erghlaw Skav Possybyl":
+    ["title", "possible-light-sleet"],
+
+  "Erghlaw Skav":
+    ["title", "light-sleet"],
+
+  "Erghlaw":
+    ["title", "medium-sleet"],
+
+  "Erghlaw Poos":
+    ["title", "heavy-sleet"],
+
+  "Ergh Skav Possybyl":
+    ["title", "possible-very-light-snow"],
+
+  "Ergh Pur Skav":
+    ["title", "very-light-snow"],
+
+  "Ergh Skav Possybyl":
+    ["title", "possible-light-snow"],
+
+  "Ergh Skav":
+    ["title", "light-snow"],
+
+  "Ergh":
+    ["title", "medium-snow"],
+
+  "Ergh Poos":
+    ["title", "heavy-snow"],
+
+  "Gwynsek":
+    ["title", "medium-wind"],
+
+  "Gwynsek Bys Yn Peryl":
+    ["title", "heavy-wind"],
+
+  "Niwlek":
+    ["title", "fog"],
+
+  "Komolek":
+    ["title", "medium-clouds"],
+
+  "Komolek Poos":
+    ["title", "heavy-clouds"],
+
+  "Sygh Ha Nebes Gwynsek":
+    ["title", ["and", "low-humidity", "light-wind"]],
+
+  "Glaw Pur Skav Ha Gwynsek Bys Yn Peryl":
+    ["title", ["and", "very-light-rain", "heavy-wind"]],
+
+  "Glyb Ha Nebes Komolek":
+    ["title", ["and", "high-humidity", "light-clouds"]],
+
+
+  "Kler rag an our.":
+    ["sentence", ["for-hour", "clear"]],
+
+  "Ergh pur skav ow talleth yn 35 myn.":
+    ["sentence", ["starting-in", "very-light-snow", ["minutes", 35]]],
+
+  "Glaw skav ow hedhi yn 15 myn.":
+    ["sentence", ["stopping-in", "light-rain", ["minutes", 15]]],
+
+  "Erghlaw poos ow talleth yn 20 myn., ow hedhi 30 myn. diwettha.":
+    ["sentence",
+      ["starting-then-stopping-later",
+        "heavy-sleet",
+        ["minutes", 20],
+        ["minutes", 30]]],
+
+  "Glaw ow hedhi yn 25 myn., ow tastalleth 8 myn. diwettha.":
+    ["sentence",
+      ["stopping-then-starting-later",
+        "medium-rain",
+        ["minutes", 25],
+        ["minutes", 8]]],
+
+
+  "Komolek dres oll an jydh.":
+    ["sentence", ["for-day", "medium-clouds"]],
+
+  "Erghlaw pur skav ow talleth y'n myttin.":
+    ["sentence", ["starting", "very-light-sleet", "morning"]],
+
+  "Gwynsek bys y'n nos ma.":
+    ["sentence", ["until", "medium-wind", "today-night"]],
+
+  "Kodhans poos bys y'n dohajydh.":
+    ["sentence", ["until", "heavy-precipitation", "afternoon"]],
+
+  "Nebes gwynsek y'n dohajydh.":
+    ["sentence", ["during", "light-wind", "afternoon"]],
+
+  "Ergh diwettha haneth ha ternos vyttin.":
+    ["sentence", ["during",
+      "medium-snow",
+      ["and", "later-today-evening", "tomorrow-morning"]]],
+
+  "Glaw poos bys yn diwettha hedhyw vyttin, ow tastalleth haneth.":
+    ["sentence", ["until-starting-again",
+      "heavy-rain",
+      "later-today-morning",
+      "today-evening"]],
+
+  "Komolek poos ow talleth y'n gorthugher, ow pesya bys y'n nos.":
+    ["sentence", ["starting-continuing-until",
+      "heavy-clouds",
+      "evening",
+      "night"]],
+
+  "Erghlaw skav diwettha an dohajydh ma ha niwlek ternos vyttin.":
+    ["sentence", ["and",
+      ["during", "light-sleet", "later-today-afternoon"],
+      ["during", "fog", "tomorrow-morning"]]],
+
+  "Gwynsek bys yn peryl ow talleth hedhyw vyttin, ow pesya bys y'n dohajydh ma, hag erghlaw ternos vyttin.":
+    ["sentence", ["and",
+      ["starting-continuing-until",
+        "heavy-wind",
+        "today-morning",
+        "today-afternoon"],
+      ["during", "medium-sleet", "tomorrow-morning"]]],
+
+  "Komolek poos ow talleth diwettha haneth hag ergh poos dohajydhweyth a-vorow.":
+    ["sentence", ["and",
+      ["starting", "heavy-clouds", "later-today-night"],
+      ["during", "heavy-snow", "tomorrow-afternoon"]]],
+
+  "Sygh y'n nos ma ha kodhans skav ow talleth gorthugherweyth a-vorow, ow pesya bys yn nosweyth a-vorow.":
+    ["sentence", ["and",
+      ["during", "low-humidity", "today-night"],
+      ["starting-continuing-until",
+        "light-precipitation",
+        "tomorrow-evening",
+        "tomorrow-night"]]],
+
+  "Ergh (5 mv.) y'n nos.":
+    ["sentence", ["during",
+      ["parenthetical", "medium-snow", ["inches", 5]],
+      "night"]],
+
+  "Ergh skav (2 cm.) diwettha hedhyw vyttin.":
+    ["sentence", ["during",
+      ["parenthetical", "light-snow", ["centimeters", 2]],
+      "later-today-morning"]],
+
+  "Ergh poos (8\u201312 mv.) dres oll an jydh.":
+    ["sentence", ["for-day",
+      ["parenthetical", "heavy-snow", ["inches", ["range", 8, 12]]]]],
+
+  "Ergh (le ages 1 cm.) y'n dohajydh.":
+    ["sentence", ["during",
+      ["parenthetical", "medium-snow", ["less-than", ["centimeters", 1]]],
+      "afternoon"]],
+
+
+  "Kodhans vyth dres oll an seythun, gans ughella tempredhow a 85\u00B0F a-vorow.":
+    ["sentence", ["with",
+      ["for-week", "no-precipitation"],
+      ["temperatures-peaking",
+        ["fahrenheit", 85],
+        "tomorrow"]]],
+
+  "Kodhans kemyskys dres an bennseythun, gans tempredhow ow kressya dhe 32\u00B0C dy' Yow.":
+    ["sentence", ["with",
+      ["over-weekend", "mixed-precipitation"],
+      ["temperatures-rising",
+        ["celsius", 32],
+        "thursday"]]],
+
+  "Glaw pur skav dy' Lun, gans tempredhow ow hedhi kodha dhe 15\u00B0F dy' Gwener.":
+    ["sentence", ["with",
+      ["during", "very-light-rain", "monday"],
+      ["temperatures-valleying",
+        ["fahrenheit", 15],
+        "friday"]]],
+
+  "Ergh skav dy' Meurth ha dy' Mergher, gans tempredhow ow kodha dhe 0\u00B0C dy' Sul.":
+    ["sentence", ["with",
+      ["during", "light-snow", ["and", "tuesday", "wednesday"]],
+      ["temperatures-falling",
+        ["celsius", 0],
+        "sunday"]]],
+
+  "Kodhans hedhyw bys yn dy' Sadorn, gans ughella tempredhow a 100\u00B0F dy' Lun.":
+    ["sentence", ["with",
+      ["during",
+        "medium-precipitation",
+        ["through", "today", "saturday"]],
+      ["temperatures-peaking",
+        ["fahrenheit", 100],
+        "monday"]]],
+
+  "Kodhans kemyskys (1\u20133 mv. a ergh) dres oll an jydh.":
+    ["sentence",
+      ["for-day",
+        ["parenthetical", "mixed-precipitation", ["inches", ["range", 1, 3]]]]],
+
+  "Ergh Poos (1\u20133 Mv.)":
+    ["title", ["parenthetical", "heavy-snow", ["inches", ["range", 1, 3]]]],
+
+  "Ergh Poos (3\u20135 cm.)":
+    ["title", ["parenthetical", "heavy-snow", ["centimeters", ["range", 3, 5]]]]
+}