Skip to content

add week and quarter for thai language in locales.py #1213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions arrow/locales.py
Original file line number Diff line number Diff line change
Expand Up @@ -4020,10 +4020,14 @@ class ThaiLocale(Locale):
"minutes": "{0} นาที",
"hour": "1 ชั่วโมง",
"hours": "{0} ชั่วโมง",
"week": "1 สัปดาห์",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @fremzuck thanks for the contribution! Mind adding some unit tests for these new cases?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a problem when using the .humanize(locale='th-th') function when the received date is more than 7 days, so I added this part. I tested it on my machine and it works fine.

What test result you want to review ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just adding a couple of basic unit tests to test this locale usage like other locales in the test_locales.py test file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, Added

"weeks": "{0} สัปดาห์",
"day": "1 วัน",
"days": "{0} วัน",
"month": "1 เดือน",
"months": "{0} เดือน",
"quarter": "1 ไตรมาส",
"quarters": "{0} ไตรมาส",
"year": "1 ปี",
"years": "{0} ปี",
}
Expand Down
8 changes: 8 additions & 0 deletions tests/test_locales.py
Original file line number Diff line number Diff line change
Expand Up @@ -1493,6 +1493,14 @@ def test_format_relative_past(self):
assert result == "ในอีก {0} ชั่วโมง"
result = self.locale._format_relative("ไม่กี่วินาที", "seconds", 42)
assert result == "ในอีกไม่กี่วินาที"
result = self.locale._format_relative("1 สัปดาห์", "week", 1)
assert result == "ในอีก 1 สัปดาห์"
result = self.locale._format_relative("{0} สัปดาห์", "weeks", 2)
assert result == "ในอีก {} สัปดาห์"
result = self.locale._format_relative("1 ไตรมาส", "quarter", 1)
assert result == "ในอีก 1 ไตรมาส"
result = self.locale._format_relative("{0} ไตรมาส", "quarters", 2)
assert result == "ในอีก {} ไตรมาส"

def test_format_relative_future(self):
result = self.locale._format_relative("1 ชั่วโมง", "hour", -1)
Expand Down
Loading