Skip to content
Open
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
6 changes: 6 additions & 0 deletions babel/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,12 @@ def parse(
if not isinstance(identifier, str):
raise TypeError(f"Unexpected value for identifier: {identifier!r}")

# C/POSIX is not a CLDR language. Same mapping default_locale uses.
posix_stem = identifier.split(".")[0].split("@")[0]
posix_stem = posix_stem.replace("-", "_")
if posix_stem.upper() in {"C", "POSIX"}:
identifier = "en_US_POSIX"

parts = parse_locale(identifier, sep=sep)
input_id = get_locale_identifier(parts)

Expand Down
6 changes: 6 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ def test_default_locale(monkeypatch):
assert default_locale() == 'en_US_POSIX'


def test_locale_parse_accepts_c_and_posix():
expected = Locale.parse('en_US_POSIX')
for value in ['C', 'c', 'POSIX', 'posix', 'C.UTF-8', 'C.utf8', 'POSIX.UTF-8']:
assert Locale.parse(value) == expected


def test_default_locale_multiple_args(monkeypatch):
for name in [
'LANGUAGE',
Expand Down