Repository navigation
docs: correct header casing claim in README - #115
Merged
Merged
Conversation
The "all keys are lowercase" line has been inaccurate since smhg#52's fix (Feb 2020): only the ~10 standard gettext headers are normalized, to their canonical Title-Case form via a case-insensitive lookup (lib/shared.js's HEADERS map), specifically so a translation tool's own custom headers (e.g. Poedit's X-Poedit-*) are preserved verbatim rather than mangled by a blanket case transform. The docs were never updated to match. Found while consuming this library directly in apache/superset -- a naive reading of the README led to looking up a parsed header with a lowercased key, silently returning undefined for every standard header. Co-Authored-By: Evan Rusackas <evan@preset.io> Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Headers section of the README says "all keys are lowercase," but that hasn't been accurate since #52's fix (Feb 2020).
lib/shared.js'sparseHeader()only normalizes the ~10 standard gettext headers (via theHEADERSmap, matched case-insensitively) to their canonical Title-Case form; any other header — e.g. a tool-specificX-Poedit-*header, which is exactly what #52 was about — keeps whatever casing the source.pofile used, untouched. The docs were just never updated to reflect that fix.Why
Ran into this directly integrating
gettext-parserinto apache/superset: a naive reading of "all keys are lowercase" led to looking up a parsed header with a lowercased key (parsed.headers.language), which silently returnedundefinedfor every real-world.pofile, since the actual key isLanguage. Wanted to send the fix back rather than just work around it locally.Change
Doc-only, no code/behavior change: replaces the stale claim with a short, accurate description of the actual (and clearly intentional, per #52) behavior.