Skip to content

fix(i18n): load locale JSON files saved with a UTF-8 BOM - #1658

Merged
harry0703 merged 1 commit into
harry0703:mainfrom
ketpatil77:fix/locale-utf8-bom
Oct 16, 2026
Merged

harry0703 merged 1 commit into
harry0703:mainfrom
ketpatil77:fix/locale-utf8-bom

Conversation

@ketpatil77

Copy link
Copy Markdown
Contributor

A locale JSON file saved with a UTF-8 BOM causes load_locales to raise JSONDecodeError while initializing translations. Read locale files with utf-8-sig so both ordinary UTF-8 and BOM-prefixed UTF-8 load successfully. Embedded U+FEFF characters and non-ASCII translations remain intact.

Validation: the BOM case failed on the original reader while plain UTF-8 passed. python -m pytest -q test/services/test_locale_encoding.py test/services/test_webui_i18n.py: 18 passed, 10,225 subtests passed. git diff --check passed; Ruff passes for the new test. Ruff on the existing utility module reports 11 pre-existing style findings; no unrelated cleanup is included. No live provider calls or full media rendering were run.

This is independent of the existing Docker documentation PR #1653.

@harry0703
harry0703 merged commit 92fb01b into harry0703:main Oct 16, 2026
3 checks passed
@harry0703

Copy link
Copy Markdown
Owner

Merged via rebase after all three CI checks passed. Thank you for the focused fix and regression test!

I also revalidated the exact PR head locally: 35 tests and 10,225 subtests passed, and Ruff passed. Running the actual Streamlit entry point with both ordinary UTF-8 and BOM-prefixed English/Chinese locale files rendered the generation form successfully in all four cases. Non-ASCII text and embedded U+FEFF characters were preserved.

The original commit message and your author attribution have been retained. Thanks again for improving locale-file compatibility!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants