From 9d825acfc818ae8563e937fa3214c60f11206cc6 Mon Sep 17 00:00:00 2001 From: "bozukov.p@gmail.com" Date: Sun, 3 Mar 2024 21:31:50 +0200 Subject: [PATCH] feat: add bg locale translations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The translations for days, months, and units in the Bulgarian (bg) locale have been updated. This update includes changes to the abbreviated, narrow, short, and wide forms of the translations. The translations for relative time expressions (e.g., "след" and "преди") have also been updated for the year, month, week, and day units. --- src/pendulum/locales/bg/__init__.py | 0 src/pendulum/locales/bg/custom.py | 22 +++ src/pendulum/locales/bg/locale.py | 221 ++++++++++++++++++++++++++++ tests/localization/test_bg.py | 87 +++++++++++ 4 files changed, 330 insertions(+) create mode 100644 src/pendulum/locales/bg/__init__.py create mode 100644 src/pendulum/locales/bg/custom.py create mode 100644 src/pendulum/locales/bg/locale.py create mode 100644 tests/localization/test_bg.py diff --git a/src/pendulum/locales/bg/__init__.py b/src/pendulum/locales/bg/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/pendulum/locales/bg/custom.py b/src/pendulum/locales/bg/custom.py new file mode 100644 index 00000000..38dc70f1 --- /dev/null +++ b/src/pendulum/locales/bg/custom.py @@ -0,0 +1,22 @@ +""" +bg custom locale file. +""" +from __future__ import annotations + + +translations = { + # Relative time + "ago": "преди {}", + "from_now": "след {}", + "after": "след {0}", + "before": "преди {0}", + # Date formats + "date_formats": { + "LTS": "HH:mm:ss", + "LT": "HH:mm", + "L": "DD.MM.YYYY", + "LL": "D MMMM YYYY г.", + "LLL": "D MMMM YYYY г., HH:mm", + "LLLL": "dddd, D MMMM YYYY г., HH:mm", + }, +} diff --git a/src/pendulum/locales/bg/locale.py b/src/pendulum/locales/bg/locale.py new file mode 100644 index 00000000..856f2f3b --- /dev/null +++ b/src/pendulum/locales/bg/locale.py @@ -0,0 +1,221 @@ +from .custom import translations as custom_translations + + +""" +bg locale file. + +It has been generated automatically and must not be modified directly. +""" + + +locale = { + 'plural': lambda n: 'one' if (n == n and ((n == 1))) else '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: 'яну', + 2: 'фев', + 3: 'март', + 4: 'апр', + 5: 'май', + 6: 'юни', + 7: 'юли', + 8: 'авг', + 9: 'сеп', + 10: 'окт', + 11: 'ное', + 12: 'дек', + }, + 'narrow': { + 1: 'я', + 2: 'ф', + 3: 'м', + 4: 'а', + 5: 'м', + 6: 'ю', + 7: 'ю', + 8: 'а', + 9: 'с', + 10: 'о', + 11: 'н', + 12: 'д', + }, + 'wide': { + 1: 'януари', + 2: 'февруари', + 3: 'март', + 4: 'април', + 5: 'май', + 6: 'юни', + 7: 'юли', + 8: 'август', + 9: 'септември', + 10: 'октомври', + 11: 'ноември', + 12: 'декември', + }, + }, + 'units': { + 'year': { + 'one': '{0} година', + 'other': '{0} години', + }, + 'month': { + 'one': '{0} месец', + 'other': '{0} месеца', + }, + 'week': { + 'one': '{0} седмица', + 'other': '{0} седмици', + }, + 'day': { + 'one': '{0} ден', + 'other': '{0} дни', + }, + 'hour': { + 'one': '{0} час', + 'other': '{0} часа', + }, + 'minute': { + 'one': '{0} минута', + 'other': '{0} минути', + }, + 'second': { + 'one': '{0} секунда', + 'other': '{0} секунди', + }, + 'microsecond': { + 'one': '{0} микросекунда', + 'other': '{0} микросекунди', + }, + }, + 'relative': { + 'year': { + 'future': { + 'other': 'след {0} години', + 'one': 'след {0} година', + }, + 'past': { + 'other': 'преди {0} години', + 'one': 'преди {0} година', + }, + }, + 'month': { + 'future': { + 'other': 'след {0} месеца', + 'one': 'след {0} месец', + }, + 'past': { + 'other': 'преди {0} месеца', + 'one': 'преди {0} месец', + }, + }, + 'week': { + 'future': { + 'other': 'след {0} седмици', + 'one': 'след {0} седмица', + }, + 'past': { + 'other': 'преди {0} седмици', + 'one': 'преди {0} седмица', + }, + }, + 'day': { + 'future': { + 'other': 'след {0} дни', + 'one': 'след {0} ден', + }, + 'past': { + 'other': 'преди {0} дни', + 'one': 'преди {0} ден', + }, + }, + 'hour': { + 'future': { + 'other': 'след {0} часа', + 'one': 'след {0} час', + }, + 'past': { + 'other': 'преди {0} часа', + 'one': 'преди {0} час', + }, + }, + 'minute': { + 'future': { + 'other': 'след {0} минути', + 'one': 'след {0} минута', + }, + 'past': { + 'other': 'преди {0} минути', + 'one': 'преди {0} минута', + }, + }, + 'second': { + 'future': { + 'other': 'след {0} секунди', + 'one': 'след {0} секунда', + }, + 'past': { + 'other': 'преди {0} секунди', + 'one': 'преди {0} секунда', + }, + }, + }, + 'day_periods': { + 'midnight': 'полунощ', + 'am': 'пр.об.', + 'pm': 'сл.об.', + 'morning1': 'сутринта', + 'morning2': 'на обяд', + 'afternoon1': 'следобед', + 'evening1': 'вечерта', + 'night1': 'през нощта', + }, + 'week_data': { + 'min_days': 1, + 'first_day': 0, + 'weekend_start': 5, + 'weekend_end': 6, + }, + }, + 'custom': custom_translations +} diff --git a/tests/localization/test_bg.py b/tests/localization/test_bg.py new file mode 100644 index 00000000..a0e317a6 --- /dev/null +++ b/tests/localization/test_bg.py @@ -0,0 +1,87 @@ +from __future__ import annotations + +import pendulum + + +locale = "bg" + + +def test_diff_for_humans(): + with pendulum.travel_to(pendulum.datetime(2016, 8, 29), freeze=True): + diff_for_humans() + + +def diff_for_humans(): + d = pendulum.now().subtract(seconds=1) + assert d.diff_for_humans(locale=locale) == "преди 1 секунда" + + d = pendulum.now().subtract(seconds=2) + assert d.diff_for_humans(locale=locale) == "преди 2 секунди" + + d = pendulum.now().subtract(seconds=5) + assert d.diff_for_humans(locale=locale) == "преди 5 секунди" + + 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(minutes=5) + assert d.diff_for_humans(locale=locale) == "преди 5 минути" + + 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(hours=5) + assert d.diff_for_humans(locale=locale) == "преди 5 часа" + + 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(days=5) + assert d.diff_for_humans(locale=locale) == "преди 5 дни" + + 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(months=5) + assert d.diff_for_humans(locale=locale) == "преди 5 месеца" + + 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().subtract(years=5) + assert d.diff_for_humans(locale=locale) == "преди 5 години" + + d = pendulum.now().add(seconds=1) + assert d.diff_for_humans(locale=locale) == "след 1 секунда" + + d = pendulum.now().add(seconds=1) + d2 = pendulum.now() + assert d.diff_for_humans(d2, locale=locale) == "след 1 секунда" + assert d2.diff_for_humans(d, locale=locale) == "преди 1 секунда" + + assert d.diff_for_humans(d2, True, locale=locale) == "1 секунда" + assert d2.diff_for_humans(d.add(seconds=1), True, locale=locale) == "2 секунди"