From ee7af5e1619bf9efad83b0999dba2e24d8185cf2 Mon Sep 17 00:00:00 2001 From: za Date: Thu, 17 Mar 2022 11:27:11 +0700 Subject: [PATCH 1/6] Initiate JA translation --- pendulum/locales/ja/__init__.py | 0 pendulum/locales/ja/custom.py | 21 ++++ pendulum/locales/ja/locale.py | 194 ++++++++++++++++++++++++++++++++ 3 files changed, 215 insertions(+) create mode 100644 pendulum/locales/ja/__init__.py create mode 100644 pendulum/locales/ja/custom.py create mode 100644 pendulum/locales/ja/locale.py diff --git a/pendulum/locales/ja/__init__.py b/pendulum/locales/ja/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pendulum/locales/ja/custom.py b/pendulum/locales/ja/custom.py new file mode 100644 index 00000000..c22d2836 --- /dev/null +++ b/pendulum/locales/ja/custom.py @@ -0,0 +1,21 @@ +""" +ja custom locale file. +""" + +translations = { + "units": {"few_second": "数秒"}, + # Relative time + "ago": "{} 前に", + "from_now": "今から {}", + "after": "{0} 後", + "before": "{0} 前", + # Date formats + "date_formats": { + "LTS": "h:mm:ss A", + "LT": "h:mm A", + "L": "MM/DD/YYYY", + "LL": "MMMM D, YYYY", + "LLL": "MMMM D, YYYY h:mm A", + "LLLL": "dddd, MMMM D, YYYY h:mm A", + }, +} \ No newline at end of file diff --git a/pendulum/locales/ja/locale.py b/pendulum/locales/ja/locale.py new file mode 100644 index 00000000..6eb8a826 --- /dev/null +++ b/pendulum/locales/ja/locale.py @@ -0,0 +1,194 @@ +from .custom import translations as custom_translations + + +""" +ja locale file. + +It has been generated automatically and must not be modified directly. +""" + + +locale = { + 'plural': lambda n: 'other', + 'ordinal': lambda n: 'other', + 'translations': { + 'days': { + 'abbreviated': { + 0: '日', + 1: '月', + 2: '火', + 3: '水', + 4: '木', + 5: '金', + 6: '土', + }, + 'narrow': { + 0: '日', + 1: '月', + 2: '火', + 3: '水', + 4: '木', + 5: '金', + 6: '土', + }, + 'short': { + 0: '日', + 1: '月', + 2: '火', + 3: '水', + 4: '木', + 5: '金', + 6: '土', + }, + 'wide': { + 0: '日曜日', + 1: '月曜日', + 2: '火曜日', + 3: '水曜日', + 4: '木曜日', + 5: '金曜日', + 6: '土曜日', + }, + }, + 'months': { + 'abbreviated': { + 1: '1月', + 2: '2月', + 3: '3月', + 4: '4月', + 5: '5月', + 6: '6月', + 7: '7月', + 8: '8月', + 9: '9月', + 10: '10月', + 11: '11月', + 12: '12月', + }, + 'narrow': { + 1: '1', + 2: '2', + 3: '3', + 4: '4', + 5: '5', + 6: '6', + 7: '7', + 8: '8', + 9: '9', + 10: '10', + 11: '11', + 12: '12', + }, + 'wide': { + 1: '1月', + 2: '2月', + 3: '3月', + 4: '4月', + 5: '5月', + 6: '6月', + 7: '7月', + 8: '8月', + 9: '9月', + 10: '10月', + 11: '11月', + 12: '12月', + }, + }, + 'units': { + 'year': { + 'other': '{0} 年', + }, + 'month': { + 'other': '{0} か月', + }, + 'week': { + 'other': '{0} 週間', + }, + 'day': { + 'other': '{0} 日', + }, + 'hour': { + 'other': '{0} 時間', + }, + 'minute': { + 'other': '{0} 分', + }, + 'second': { + 'other': '{0} 秒', + }, + 'microsecond': { + 'other': '{0} マイクロ秒', + }, + }, + 'relative': { + 'year': { + 'future': { + 'other': '{0} 年後', + }, + 'past': { + 'other': '{0} 年前', + }, + }, + 'month': { + 'future': { + 'other': '{0} か月後', + }, + 'past': { + 'other': '{0} か月前', + }, + }, + 'week': { + 'future': { + 'other': '{0} 週間後', + }, + 'past': { + 'other': '{0} 週間前', + }, + }, + 'day': { + 'future': { + 'other': '{0} 日後', + }, + 'past': { + 'other': '{0} 日前', + }, + }, + 'hour': { + 'future': { + 'other': '{0} 時間後', + }, + 'past': { + 'other': '{0} 時間前', + }, + }, + 'minute': { + 'future': { + 'other': '{0} 分後', + }, + 'past': { + 'other': '{0} 分前', + }, + }, + 'second': { + 'future': { + 'other': '{0} 秒後', + }, + 'past': { + 'other': '{0} 秒前', + }, + }, + }, + 'day_periods': { + 'midnight': '真夜中', + 'am': '午前', + 'noon': '正午', + 'pm': '午後', + 'morning1': '朝', + 'afternoon1': '昼', + 'evening1': '夕方', + 'night1': '夜', + 'night2': '夜中', + }, + }, + 'custom': custom_translations +} From 2ba9365fbb13c0d8147b7ab380578c0bc96c579a Mon Sep 17 00:00:00 2001 From: za Date: Tue, 22 Mar 2022 08:10:13 +0700 Subject: [PATCH 2/6] Initiate JA test code --- tests/localization/test_ja.py | 67 +++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tests/localization/test_ja.py diff --git a/tests/localization/test_ja.py b/tests/localization/test_ja.py new file mode 100644 index 00000000..69178cbf --- /dev/null +++ b/tests/localization/test_ja.py @@ -0,0 +1,67 @@ +import pendulum + + +locale = "ja" + + +def test_diff_for_humans(): + with pendulum.test(pendulum.datetime(2016, 8, 29)): + diff_for_humans() + + +def diff_for_humans(): + d = pendulum.now().subtract(seconds=1) + assert d.diff_for_humans(locale=locale) == "数秒" + + d = pendulum.now().subtract(seconds=2) + assert d.diff_for_humans(locale=locale) == "数秒" + + d = pendulum.now().subtract(seconds=21) + assert d.diff_for_humans(locale=locale) == "21 前に" + + d = pendulum.now().subtract(minutes=1) + assert d.diff_for_humans(locale=locale) == "1 分前" + + d = pendulum.now().subtract(minutes=2) + assert d.diff_for_humans(locale=locale) == "2 分前" + + d = pendulum.now().subtract(hours=1) + assert d.diff_for_humans(locale=locale) == "1 時間前" + + d = pendulum.now().subtract(hours=2) + assert d.diff_for_humans(locale=locale) == "2 時間前" + + d = pendulum.now().subtract(days=1) + assert d.diff_for_humans(locale=locale) == "1 日前" + + d = pendulum.now().subtract(days=2) + assert d.diff_for_humans(locale=locale) == "2 日前" + + d = pendulum.now().subtract(weeks=1) + assert d.diff_for_humans(locale=locale) == "1 週間前" + + d = pendulum.now().subtract(weeks=2) + assert d.diff_for_humans(locale=locale) == "2 週間前" + + d = pendulum.now().subtract(months=1) + assert d.diff_for_humans(locale=locale) == "1 か月前" + + d = pendulum.now().subtract(months=2) + assert d.diff_for_humans(locale=locale) == "2 か月前" + + d = pendulum.now().subtract(years=1) + assert d.diff_for_humans(locale=locale) == "1 年前" + + d = pendulum.now().subtract(years=2) + assert d.diff_for_humans(locale=locale) == "2 年前" + + d = pendulum.now().add(seconds=1) + assert d.diff_for_humans(locale=locale) == "数秒" + + d = pendulum.now().add(seconds=1) + d2 = pendulum.now() + assert d.diff_for_humans(d2, locale=locale) == "秒後" + assert d2.diff_for_humans(d, locale=locale) == "秒前" + + assert d.diff_for_humans(d2, True, locale=locale) == "秒前" + assert d2.diff_for_humans(d.add(seconds=1), True, locale=locale) == "秒前" From b149b71c197153c351cd1d91bda910bf15d72616 Mon Sep 17 00:00:00 2001 From: Bartosz Sokorski Date: Sun, 7 Aug 2022 16:40:45 +0200 Subject: [PATCH 3/6] Update custom.py --- pendulum/locales/ja/custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pendulum/locales/ja/custom.py b/pendulum/locales/ja/custom.py index c22d2836..c0762503 100644 --- a/pendulum/locales/ja/custom.py +++ b/pendulum/locales/ja/custom.py @@ -18,4 +18,4 @@ "LLL": "MMMM D, YYYY h:mm A", "LLLL": "dddd, MMMM D, YYYY h:mm A", }, -} \ No newline at end of file +} From 0a9facaac565a27d783f909690f2720411da2198 Mon Sep 17 00:00:00 2001 From: za Date: Mon, 15 Aug 2022 16:17:43 +0700 Subject: [PATCH 4/6] Update assert in the test code --- tests/localization/test_ja.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/localization/test_ja.py b/tests/localization/test_ja.py index 69178cbf..87691bdd 100644 --- a/tests/localization/test_ja.py +++ b/tests/localization/test_ja.py @@ -11,13 +11,13 @@ def test_diff_for_humans(): def diff_for_humans(): d = pendulum.now().subtract(seconds=1) - assert d.diff_for_humans(locale=locale) == "数秒" + assert d.diff_for_humans(locale=locale) == "数秒 前に" d = pendulum.now().subtract(seconds=2) - assert d.diff_for_humans(locale=locale) == "数秒" + assert d.diff_for_humans(locale=locale) == "数秒 前に" d = pendulum.now().subtract(seconds=21) - assert d.diff_for_humans(locale=locale) == "21 前に" + assert d.diff_for_humans(locale=locale) == "21 秒前" d = pendulum.now().subtract(minutes=1) assert d.diff_for_humans(locale=locale) == "1 分前" @@ -56,12 +56,12 @@ def diff_for_humans(): assert d.diff_for_humans(locale=locale) == "2 年前" d = pendulum.now().add(seconds=1) - assert d.diff_for_humans(locale=locale) == "数秒" + assert d.diff_for_humans(locale=locale) == "今から 数秒" d = pendulum.now().add(seconds=1) d2 = pendulum.now() - assert d.diff_for_humans(d2, locale=locale) == "秒後" - assert d2.diff_for_humans(d, locale=locale) == "秒前" + assert d.diff_for_humans(d2, locale=locale) == "数秒 後" + assert d2.diff_for_humans(d, locale=locale) == "数秒 前" - assert d.diff_for_humans(d2, True, locale=locale) == "秒前" - assert d2.diff_for_humans(d.add(seconds=1), True, locale=locale) == "秒前" + assert d.diff_for_humans(d2, True, locale=locale) == "数秒" + assert d2.diff_for_humans(d.add(seconds=1), True, locale=locale) == "数秒" From 4161c4a9420b39f059bd69963f5eaf81aa2bdb47 Mon Sep 17 00:00:00 2001 From: za Date: Mon, 15 Aug 2022 16:23:20 +0700 Subject: [PATCH 5/6] Reformat locale.py using black --- pendulum/locales/ja/locale.py | 290 +++++++++++++++++----------------- 1 file changed, 145 insertions(+), 145 deletions(-) diff --git a/pendulum/locales/ja/locale.py b/pendulum/locales/ja/locale.py index 6eb8a826..574d2ec0 100644 --- a/pendulum/locales/ja/locale.py +++ b/pendulum/locales/ja/locale.py @@ -9,186 +9,186 @@ locale = { - 'plural': lambda n: 'other', - 'ordinal': lambda n: 'other', - 'translations': { - 'days': { - 'abbreviated': { - 0: '日', - 1: '月', - 2: '火', - 3: '水', - 4: '木', - 5: '金', - 6: '土', - }, - 'narrow': { - 0: '日', - 1: '月', - 2: '火', - 3: '水', - 4: '木', - 5: '金', - 6: '土', - }, - 'short': { - 0: '日', - 1: '月', - 2: '火', - 3: '水', - 4: '木', - 5: '金', - 6: '土', - }, - 'wide': { - 0: '日曜日', - 1: '月曜日', - 2: '火曜日', - 3: '水曜日', - 4: '木曜日', - 5: '金曜日', - 6: '土曜日', + "plural": lambda n: "other", + "ordinal": lambda n: "other", + "translations": { + "days": { + "abbreviated": { + 0: "日", + 1: "月", + 2: "火", + 3: "水", + 4: "木", + 5: "金", + 6: "土", + }, + "narrow": { + 0: "日", + 1: "月", + 2: "火", + 3: "水", + 4: "木", + 5: "金", + 6: "土", + }, + "short": { + 0: "日", + 1: "月", + 2: "火", + 3: "水", + 4: "木", + 5: "金", + 6: "土", + }, + "wide": { + 0: "日曜日", + 1: "月曜日", + 2: "火曜日", + 3: "水曜日", + 4: "木曜日", + 5: "金曜日", + 6: "土曜日", }, }, - 'months': { - 'abbreviated': { - 1: '1月', - 2: '2月', - 3: '3月', - 4: '4月', - 5: '5月', - 6: '6月', - 7: '7月', - 8: '8月', - 9: '9月', - 10: '10月', - 11: '11月', - 12: '12月', - }, - 'narrow': { - 1: '1', - 2: '2', - 3: '3', - 4: '4', - 5: '5', - 6: '6', - 7: '7', - 8: '8', - 9: '9', - 10: '10', - 11: '11', - 12: '12', - }, - 'wide': { - 1: '1月', - 2: '2月', - 3: '3月', - 4: '4月', - 5: '5月', - 6: '6月', - 7: '7月', - 8: '8月', - 9: '9月', - 10: '10月', - 11: '11月', - 12: '12月', + "months": { + "abbreviated": { + 1: "1月", + 2: "2月", + 3: "3月", + 4: "4月", + 5: "5月", + 6: "6月", + 7: "7月", + 8: "8月", + 9: "9月", + 10: "10月", + 11: "11月", + 12: "12月", + }, + "narrow": { + 1: "1", + 2: "2", + 3: "3", + 4: "4", + 5: "5", + 6: "6", + 7: "7", + 8: "8", + 9: "9", + 10: "10", + 11: "11", + 12: "12", + }, + "wide": { + 1: "1月", + 2: "2月", + 3: "3月", + 4: "4月", + 5: "5月", + 6: "6月", + 7: "7月", + 8: "8月", + 9: "9月", + 10: "10月", + 11: "11月", + 12: "12月", }, }, - 'units': { - 'year': { - 'other': '{0} 年', + "units": { + "year": { + "other": "{0} 年", }, - 'month': { - 'other': '{0} か月', + "month": { + "other": "{0} か月", }, - 'week': { - 'other': '{0} 週間', + "week": { + "other": "{0} 週間", }, - 'day': { - 'other': '{0} 日', + "day": { + "other": "{0} 日", }, - 'hour': { - 'other': '{0} 時間', + "hour": { + "other": "{0} 時間", }, - 'minute': { - 'other': '{0} 分', + "minute": { + "other": "{0} 分", }, - 'second': { - 'other': '{0} 秒', + "second": { + "other": "{0} 秒", }, - 'microsecond': { - 'other': '{0} マイクロ秒', + "microsecond": { + "other": "{0} マイクロ秒", }, }, - 'relative': { - 'year': { - 'future': { - 'other': '{0} 年後', + "relative": { + "year": { + "future": { + "other": "{0} 年後", }, - 'past': { - 'other': '{0} 年前', + "past": { + "other": "{0} 年前", }, }, - 'month': { - 'future': { - 'other': '{0} か月後', + "month": { + "future": { + "other": "{0} か月後", }, - 'past': { - 'other': '{0} か月前', + "past": { + "other": "{0} か月前", }, }, - 'week': { - 'future': { - 'other': '{0} 週間後', + "week": { + "future": { + "other": "{0} 週間後", }, - 'past': { - 'other': '{0} 週間前', + "past": { + "other": "{0} 週間前", }, }, - 'day': { - 'future': { - 'other': '{0} 日後', + "day": { + "future": { + "other": "{0} 日後", }, - 'past': { - 'other': '{0} 日前', + "past": { + "other": "{0} 日前", }, }, - 'hour': { - 'future': { - 'other': '{0} 時間後', + "hour": { + "future": { + "other": "{0} 時間後", }, - 'past': { - 'other': '{0} 時間前', + "past": { + "other": "{0} 時間前", }, }, - 'minute': { - 'future': { - 'other': '{0} 分後', + "minute": { + "future": { + "other": "{0} 分後", }, - 'past': { - 'other': '{0} 分前', + "past": { + "other": "{0} 分前", }, }, - 'second': { - 'future': { - 'other': '{0} 秒後', + "second": { + "future": { + "other": "{0} 秒後", }, - 'past': { - 'other': '{0} 秒前', + "past": { + "other": "{0} 秒前", }, }, }, - 'day_periods': { - 'midnight': '真夜中', - 'am': '午前', - 'noon': '正午', - 'pm': '午後', - 'morning1': '朝', - 'afternoon1': '昼', - 'evening1': '夕方', - 'night1': '夜', - 'night2': '夜中', + "day_periods": { + "midnight": "真夜中", + "am": "午前", + "noon": "正午", + "pm": "午後", + "morning1": "朝", + "afternoon1": "昼", + "evening1": "夕方", + "night1": "夜", + "night2": "夜中", }, }, - 'custom': custom_translations + "custom": custom_translations, } From f4e819f8e2a43c7c24a6745ef68eb0e4f8d76209 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 16 Aug 2022 07:14:20 +0000 Subject: [PATCH 6/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/localization/test_ja.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/localization/test_ja.py b/tests/localization/test_ja.py index 87691bdd..9dba6091 100644 --- a/tests/localization/test_ja.py +++ b/tests/localization/test_ja.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pendulum