Skip to content

Decode JavaScript Unicode code point escapes during extraction - #1394

Open
theman6660 wants to merge 1 commit into
python-babel:masterfrom
theman6660:fix/js-unicode-codepoint-escapes
Open

theman6660 wants to merge 1 commit into
python-babel:masterfrom
theman6660:fix/js-unicode-codepoint-escapes

Conversation

@theman6660

Copy link
Copy Markdown

JavaScript gettext("Hello \u{1F600}") evaluates to "Hello 😀", but extraction currently produces the literal text "Hello u{1F600}". The resulting translation key does not match the runtime message.

Recognize lowercase-u braced hexadecimal escapes in unquote_string(), including supplementary code points and leading zeros. Preserve the existing fallback for malformed or out-of-range escapes and leave legacy hexadecimal/Unicode handling intact.

Add 29 cases across single/double quotes and template strings, including the public JavaScript extraction API, line numbers, NUL, BMP and maximum code points, adjacent/legacy escapes and malformed inputs. Before the fix, 23 failed and 6 passed. All 29 now pass; the focused lexer/extractor set has 49 passing tests. A separate Node.js runtime check agrees on 30 valid literal values. Full Babel suite with imported CLDR 48.2: 7860 passed, 7 skipped, 2 xfailed (one existing pytest deprecation warning). Project pre-commit hooks and git diff --check pass.

Prepared with OpenAI Codex assistance. No production usage, human review or upstream CI is claimed.

This branch has not been deployed

No deployments
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.

1 participant