Skip to content
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

Workaround Turkish locale issue on Windows #3301

Merged
merged 1 commit into from
Apr 19, 2024
Merged
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
8 changes: 8 additions & 0 deletions pelican/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ class DateFormatter:

def __init__(self) -> None:
self.locale = locale.setlocale(locale.LC_TIME)
# python has issue with Turkish_Türkiye.1254 locale, replace it to
# something accepted: Turkish
if self.locale == "Turkish_Türkiye.1254":
self.locale = "Turkish"

def __call__(self, date: datetime.datetime, date_format: str) -> str:
# on OSX, encoding from LC_CTYPE determines the unicode output in PY3
Expand Down Expand Up @@ -922,6 +926,10 @@ def temporary_locale(
class to use the C locale.
"""
orig_locale = locale.setlocale(lc_category)
# python has issue with Turkish_Türkiye.1254 locale, replace it to
# something accepted: Turkish
if orig_locale == "Turkish_Türkiye.1254":
orig_locale = "Turkish"
if temp_locale:
locale.setlocale(lc_category, temp_locale)
yield
Expand Down
Loading