Repository: darkskyapp/forecast-io-translations
Pull request #155 (2017-08-21 17:44:12)

Japanese translation
Japanese translation with test case.


Patch:
diff --git a/lib/lang/jp.js b/lib/lang/jp.js
new file mode 100644
index 0000000..f63b416
--- /dev/null
+++ b/lib/lang/jp.js
@@ -0,0 +1,136 @@
+function join_with_shared_prefix(a, b, joiner) {
+  var 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.slice(0, i) + a.slice(i) + joiner + b.slice(i);
+}
+
+module.exports = require("../template")({
+  "clear": "晴れ",
+  "no-precipitation": "降水なし",
+  "mixed-precipitation": "みぞれ",
+  "possible-very-light-precipitation": "弱い降水の可能性あり",
+  "very-light-precipitation": "弱い降水",
+  "possible-light-precipitation": "弱い降水の可能性あり",
+  "light-precipitation": "弱い降水",
+  "medium-precipitation": "降水",
+  "heavy-precipitation": "強い降水",
+  "possible-very-light-rain": "霧雨の可能性あり",
+  "very-light-rain": "霧雨",
+  "possible-light-rain": "小雨の可能性あり",
+  "light-rain": "小雨",
+  "medium-rain": "雨",
+  "heavy-rain": "大雨",
+  "possible-very-light-sleet": "弱いみぞれの可能性あり",
+  "very-light-sleet": "弱いみぞれ",
+  "possible-light-sleet": "弱いみぞれの可能性あり",
+  "light-sleet": "弱いみぞれ",
+  "medium-sleet": "みぞれ",
+  "heavy-sleet": "強いみぞれ",
+  "possible-very-light-snow": "にわか雪の可能性があり",
+  "very-light-snow": "にわか雪",
+  "possible-light-snow": "小雪の可能性があり",
+  "light-snow": "小雪",
+  "medium-snow": "雪",
+  "heavy-snow": "大雪",
+  "possible-thunderstorm": "激しい雷雨の可能性があり",
+  "thunderstorm": "雷雨",
+  "light-wind": "弱い風",
+  "medium-wind": "強い風",
+  "heavy-wind": "猛烈な風",
+  "low-humidity": "乾燥",
+  "high-humidity": "湿っぽい",
+  "fog": "霧",
+  "light-clouds": "薄曇り",
+  "medium-clouds": "曇り",
+  "heavy-clouds": "曇り",
+  "today-morning": "今朝",
+  "later-today-morning": "今日の午前中",
+  "today-afternoon": "今日の昼過ぎ",
+  "later-today-afternoon": "今日の夕方",
+  "today-evening": "今日の夜の初め頃",
+  "later-today-evening": "今日の夜遅く",
+  "today-night": "今夜",
+  "later-today-night": "今夜遅く",
+  "tomorrow-morning": "明日の朝",
+  "tomorrow-afternoon": "明日の昼過ぎ",
+  "tomorrow-evening": "明日の夕方",
+  "tomorrow-night": "明日の夜",
+  "morning": "朝",
+  "afternoon": "昼過ぎ",
+  "evening": "夕方",
+  "night": "夜",
+  "today": "今日",
+  "tomorrow": "明日",
+  "sunday": "日曜日",
+  "monday": "月曜日",
+  "tuesday": "火曜日",
+  "wednesday": "水曜日",
+  "thursday": "木曜日",
+  "friday": "金曜日",
+  "saturday": "土曜日",
+  "next-sunday": "次の日曜日",
+  "next-monday": "次の月曜日",
+  "next-tuesday": "次の火曜日",
+  "next-wednesday": "次の水曜日",
+  "next-thursday": "次の木曜日",
+  "next-friday": "次の金曜日",
+  "next-saturday": "次の土曜日",
+  "minutes": "$1分",
+  "fahrenheit": "$1\u00B0F",
+  "celsius": "$1\u00B0C",
+  "inches": "$1インチ",
+  "centimeters": "$1センチメートル",
+  "less-than": "$1未満",
+  "and": function(a, b) {
+    return join_with_shared_prefix(
+      a,
+      b,
+      a.indexOf(",") !== -1 ? ",及び" : "及び"
+    );
+  },
+  "through": function(a, b) {
+    return join_with_shared_prefix(a, b, " から ");
+  },
+  "with": "$1及び$2",
+  "range": "$1\u2013$2",
+  "parenthetical": "$1 ($2)",
+  "for-hour": "一時間$1",
+  "starting-in": "$1が$2に始まります",
+  "stopping-in": "$1が$2に終わります",
+  "starting-then-stopping-later": "$1が$2に始まり、$3後終わります",
+  "stopping-then-starting-later": "$1が$2に終わり、また$3後始まります",
+  "for-day": "一日中$1",
+  "starting": "$1は$2が始まります",
+  "until": function(condition, period) {
+    return  condition + period + " まで" ;
+  },
+  "until-starting-again": function(condition, a, b) {
+    return condition + a + "まで" + b +  ", また始まる " ;
+  },
+  "starting-continuing-until": function(condition, a, b) {
+    return condition + a + " 始まって" + b + ", まで続く " ;
+  },
+  "during": "$1から$2にかけて",
+  "for-week": "一週間中$1",
+  "over-weekend": "土、日曜日に$1",
+  "temperatures-peaking": "最高気温$1 $2",
+  "temperatures-rising": "気温は$1 $2に上がります",
+  "temperatures-valleying": "最低気温$1 $2",
+  "temperatures-falling": "気温は$1 $2に下がります",
+  "title": "$1",
+  /* Add a period if there isn't already one. */
+  "sentence": function(str) {
+    if(str.charAt(str.length - 1) !== "。")
+      str += "。";
+
+    return str;
+  }
+});


Test patch:
diff --git a/test_cases/jp.json b/test_cases/jp.json
new file mode 100644
index 0000000..41d756a
--- /dev/null
+++ b/test_cases/jp.json
@@ -0,0 +1,258 @@
+{
+  "晴れ":
+    ["title", "clear"],
+
+  "弱い降水の可能性あり":
+    ["title", "possible-very-light-precipitation"],
+
+  "弱い降水":
+    ["title", "very-light-precipitation"],
+
+  "弱い降水の可能性あり":
+    ["title", "possible-light-precipitation"],
+
+  "弱い降水":
+    ["title", "light-precipitation"],
+
+  "降水":
+    ["title", "medium-precipitation"],
+
+  "強い降水":
+    ["title", "heavy-precipitation"],
+
+  "霧雨の可能性あり":
+    ["title", "possible-very-light-rain"],
+
+  "霧雨":
+    ["title", "very-light-rain"],
+
+  "小雨の可能性あり":
+    ["title", "possible-light-rain"],
+
+  "小雨":
+    ["title", "light-rain"],
+
+  "雨":
+    ["title", "medium-rain"],
+
+  "大雨":
+    ["title", "heavy-rain"],
+
+  "弱いみぞれの可能性あり":
+    ["title", "possible-very-light-sleet"],
+
+  "弱いみぞれ":
+    ["title", "very-light-sleet"],
+
+  "弱いみぞれの可能性あり":
+    ["title", "possible-light-sleet"],
+
+  "弱いみぞれ":
+    ["title", "light-sleet"],
+
+  "みぞれ":
+    ["title", "medium-sleet"],
+
+  "強いみぞれ":
+    ["title", "heavy-sleet"],
+
+  "にわか雪の可能性があり":
+    ["title", "possible-very-light-snow"],
+
+  "にわか雪":
+    ["title", "very-light-snow"],
+
+  "小雪の可能性があり":
+    ["title", "possible-light-snow"],
+
+  "小雪":
+    ["title", "light-snow"],
+
+  "雪":
+    ["title", "medium-snow"],
+
+  "大雪":
+    ["title", "heavy-snow"],
+
+  "強い風":
+    ["title", "medium-wind"],
+
+  "猛烈な風":
+    ["title", "heavy-wind"],
+
+  "霧":
+    ["title", "fog"],
+
+  "曇り":
+    ["title", "medium-clouds"],
+
+  "曇り":
+    ["title", "heavy-clouds"],
+
+  "乾燥及び弱い風":
+    ["title", ["and", "low-humidity", "light-wind"]],
+
+  "霧雨及び猛烈な風":
+    ["title", ["and", "very-light-rain", "heavy-wind"]],
+
+  "湿っぽい及び薄曇り":
+    ["title", ["and", "high-humidity", "light-clouds"]],
+
+  "一時間晴れ。":
+    ["sentence", ["for-hour", "clear"]],
+
+  "にわか雪が35分に始まります。":
+    ["sentence", ["starting-in", "very-light-snow", ["minutes", 35]]],
+
+  "小雨が15分に終わります。":
+    ["sentence", ["stopping-in", "light-rain", ["minutes", 15]]],
+
+  "強いみぞれが20分に始まり、30分後終わります。":
+    ["sentence",
+      ["starting-then-stopping-later",
+        "heavy-sleet",
+        ["minutes", 20],
+        ["minutes", 30]]],
+
+  "雨が25分に終わり、また8分後始まります。":
+    ["sentence",
+      ["stopping-then-starting-later",
+        "medium-rain",
+        ["minutes", 25],
+        ["minutes", 8]]],
+
+  "一日中曇り。":
+    ["sentence", ["for-day", "medium-clouds"]],
+
+  "弱いみぞれは朝が始まります。":
+    ["sentence", ["starting", "very-light-sleet", "morning"]],
+
+  "強い風今夜 まで。":
+    ["sentence", ["until", "medium-wind", "today-night"]],
+
+  "強い降水昼過ぎ まで。":
+    ["sentence", ["until", "heavy-precipitation", "afternoon"]],
+
+  "弱い風から昼過ぎにかけて。":
+    ["sentence", ["during", "light-wind", "afternoon"]],
+ 
+ "雪から今日の夜遅く及び明日の朝にかけて。":
+    ["sentence", ["during",
+      "medium-snow",
+      ["and", "later-today-evening", "tomorrow-morning"]]],
+
+  "大雨今日の午前中まで今日の夜の初め頃, また始まる 。":
+    ["sentence", ["until-starting-again",
+      "heavy-rain",
+      "later-today-morning",
+      "today-evening"]],
+
+  "曇り夕方 始まって夜, まで続く 。":
+    ["sentence", ["starting-continuing-until",
+      "heavy-clouds",
+      "evening",
+      "night"]],
+
+  "弱いみぞれから今日の夕方にかけて及び霧から明日の朝にかけて。":
+    ["sentence", ["and",
+      ["during", "light-sleet", "later-today-afternoon"],
+      ["during", "fog", "tomorrow-morning"]]],
+
+  "猛烈な風今朝 始まって今日の昼過ぎ, まで続く ,及びみぞれから明日の朝にかけて。":
+    ["sentence", ["and",
+      ["starting-continuing-until",
+        "heavy-wind",
+        "today-morning",
+        "today-afternoon"],
+      ["during", "medium-sleet", "tomorrow-morning"]]],
+
+  "曇りは今夜遅くが始まります及び大雪から明日の昼過ぎにかけて。":
+    ["sentence", ["and",
+      ["starting", "heavy-clouds", "later-today-night"],
+      ["during", "heavy-snow", "tomorrow-afternoon"]]],
+
+  "乾燥から今夜にかけて及び弱い降水明日の夕方 始まって明日の夜, まで続く 。":
+    ["sentence", ["and",
+      ["during", "low-humidity", "today-night"],
+      ["starting-continuing-until",
+        "light-precipitation",
+        "tomorrow-evening",
+        "tomorrow-night"]]],
+
+  "雪 (5インチ)から夜にかけて。":
+    ["sentence", ["during",
+      ["parenthetical", "medium-snow", ["inches", 5]],
+      "night"]],
+
+  "小雪 (2センチメートル)から今日の午前中にかけて。":
+    ["sentence", ["during",
+      ["parenthetical", "light-snow", ["centimeters", 2]],
+      "later-today-morning"]],
+
+  "一日中大雪 (8–12インチ)。":
+    ["sentence", ["for-day",
+      ["parenthetical", "heavy-snow", ["inches", ["range", 8, 12]]]]],
+
+  "雪 (1センチメートル未満)から昼過ぎにかけて。":
+    ["sentence", ["during",
+      ["parenthetical", "medium-snow", ["less-than", ["centimeters", 1]]],
+      "afternoon"]],
+
+  "一週間中降水なし及び最高気温85°F 明日。":
+    ["sentence", ["with",
+      ["for-week", "no-precipitation"],
+      ["temperatures-peaking",
+        ["fahrenheit", 85],
+        "tomorrow"]]],
+
+  "土、日曜日にみぞれ及び気温は32°C 木曜日に上がります。":
+    ["sentence", ["with",
+      ["over-weekend", "mixed-precipitation"],
+      ["temperatures-rising",
+        ["celsius", 32],
+        "thursday"]]],
+
+  "霧雨から月曜日にかけて及び最低気温15°F 金曜日。":
+    ["sentence", ["with",
+      ["during", "very-light-rain", "monday"],
+      ["temperatures-valleying",
+        ["fahrenheit", 15],
+        "friday"]]],
+
+  "小雪から火曜日及び次の水曜日にかけて及び気温は0°C 日曜日に下がります。":
+    ["sentence", ["with",
+      ["during", "light-snow", ["and", "tuesday", "next-wednesday"]],
+      ["temperatures-falling",
+        ["celsius", 0],
+        "sunday"]]],
+
+  "降水から今日 から 土曜日にかけて及び最高気温100°F 月曜日。":
+    ["sentence", ["with",
+      ["during",
+        "medium-precipitation",
+        ["through", "today", "saturday"]],
+      ["temperatures-peaking",
+        ["fahrenheit", 100],
+        "monday"]]],
+
+  "一日中みぞれ (1–3インチ)。":
+    ["sentence",
+      ["for-day",
+        ["parenthetical", "mixed-precipitation", ["inches", ["range", 1, 3]]]]],
+
+  "大雪 (1–3インチ)":
+    ["title", ["parenthetical", "heavy-snow", ["inches", ["range", 1, 3]]]],
+
+  "大雪 (3–5センチメートル)":
+    ["title", ["parenthetical", "heavy-snow", ["centimeters", ["range", 3, 5]]]],
+
+  "激しい雷雨の可能性があり":
+    ["title", "possible-thunderstorm"],
+
+  "大雨及び雷雨":
+    ["title", ["and", "heavy-rain", "thunderstorm"]],
+
+  "霧雨が1分未満に始まります。":
+    ["sentence",
+      ["starting-in", "very-light-rain", ["less-than", ["minutes", 1]]]]
+}