Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d8bf13d

Browse files
Add week, weeks to timeframes in class ThaiLocale (#1218)
* Add week, weeks to timeframes in class ThaiLocale * Update ThaiLocale translations and add tests for timeframes and weekdays * Format day_names in ThaiLocale for improved readability
1 parent 0fe5f06 commit d8bf13d

File tree

2 files changed

+57
-8
lines changed

2 files changed

+57
-8
lines changed

‎arrow/locales.py‎

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4015,16 +4015,18 @@ class ThaiLocale(Locale):
40154015
timeframes = {
40164016
"now": "ขณะนี้",
40174017
"second": "วินาที",
4018-
"seconds": "{0} ไม่กี่วินาที",
4019-
"minute": "1 นาที",
4018+
"seconds": "{0} วินาที",
4019+
"minute": "นาที",
40204020
"minutes": "{0} นาที",
4021-
"hour": "1 ชั่วโมง",
4021+
"hour": "ชั่วโมง",
40224022
"hours": "{0} ชั่วโมง",
4023-
"day": "1 วัน",
4023+
"day": "วัน",
40244024
"days": "{0} วัน",
4025-
"month": "1 เดือน",
4025+
"week": "สัปดาห์",
4026+
"weeks": "{0} สัปดาห์",
4027+
"month": "เดือน",
40264028
"months": "{0} เดือน",
4027-
"year": "1 ปี",
4029+
"year": "ปี",
40284030
"years": "{0} ปี",
40294031
}
40304032

@@ -4059,8 +4061,17 @@ class ThaiLocale(Locale):
40594061
"ธ.ค.",
40604062
]
40614063

4062-
day_names = ["", "จันทร์", "อังคาร", "พุธ", "พฤหัสบดี", "ศุกร์", "เสาร์", "อาทิตย์"]
4063-
day_abbreviations = ["", "จ", "อ", "พ", "พฤ", "ศ", "ส", "อา"]
4064+
day_names = [
4065+
"",
4066+
"วันจันทร์",
4067+
"วันอังคาร",
4068+
"วันพุธ",
4069+
"วันพฤหัสบดี",
4070+
"วันศุกร์",
4071+
"วันเสาร์",
4072+
"วันอาทิตย์",
4073+
]
4074+
day_abbreviations = ["", "จ.", "อ.", "พ.", "พฤ.", "ศ.", "ส.", "อา."]
40644075

40654076
meridians = {"am": "am", "pm": "pm", "AM": "AM", "PM": "PM"}
40664077

‎tests/test_locales.py‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,44 @@ def test_format_relative_future(self):
14981498
result = self.locale._format_relative("1 ชั่วโมง", "hour", -1)
14991499
assert result == "1 ชั่วโมง ที่ผ่านมา"
15001500

1501+
def test_format_timeframe(self):
1502+
# Now
1503+
assert self.locale._format_timeframe("now", 0) == "ขณะนี้"
1504+
# Second(s)
1505+
assert self.locale._format_timeframe("second", 1) == "วินาที"
1506+
assert self.locale._format_timeframe("seconds", 2) == "2 วินาที"
1507+
# Minute(s)
1508+
assert self.locale._format_timeframe("minute", 1) == "นาที"
1509+
assert self.locale._format_timeframe("minutes", 5) == "5 นาที"
1510+
# Hour(s)
1511+
assert self.locale._format_timeframe("hour", 1) == "ชั่วโมง"
1512+
assert self.locale._format_timeframe("hours", 3) == "3 ชั่วโมง"
1513+
# Day(s)
1514+
assert self.locale._format_timeframe("day", 1) == "วัน"
1515+
assert self.locale._format_timeframe("days", 7) == "7 วัน"
1516+
# Week(s)
1517+
assert self.locale._format_timeframe("week", 1) == "สัปดาห์"
1518+
assert self.locale._format_timeframe("weeks", 2) == "2 สัปดาห์"
1519+
# Month(s)
1520+
assert self.locale._format_timeframe("month", 1) == "เดือน"
1521+
assert self.locale._format_timeframe("months", 4) == "4 เดือน"
1522+
# Year(s)
1523+
assert self.locale._format_timeframe("year", 1) == "ปี"
1524+
assert self.locale._format_timeframe("years", 10) == "10 ปี"
1525+
1526+
def test_weekday(self):
1527+
dt = arrow.Arrow(2015, 4, 11, 17, 30, 0)
1528+
# These values depend on the actual Thai locale implementation
1529+
# Replace with correct Thai names if available
1530+
assert self.locale.day_name(dt.isoweekday()) == "วันเสาร์"
1531+
assert self.locale.day_abbreviation(dt.isoweekday()) == "ส."
1532+
1533+
def test_ordinal_number(self):
1534+
# Thai ordinal numbers are not commonly used, but test for fallback
1535+
assert self.locale.ordinal_number(1) == "1"
1536+
assert self.locale.ordinal_number(10) == "10"
1537+
assert self.locale.ordinal_number(0) == "0"
1538+
15011539

15021540
@pytest.mark.usefixtures("lang_locale")
15031541
class TestBengaliLocale:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /