Fix case-insensitive language code matching#287
Open
rathboma wants to merge 3 commits intountra:mainfrom
Open
Conversation
Fixes issue where documents with language codes in different cases (e.g., lang: pt-br) were not processed when config had different casing (e.g., languages: ['pt-BR']), causing: - Documents silently skipped during coordination - Files generated in _site/pt-BR/ but URLs using /pt-br/ - 404 errors and broken hreflang links Changes: - Add normalization infrastructure to Site class - Normalize language codes early in coordinate_documents - Use case-insensitive matching for all language comparisons - Preserve original config case for file paths and URLs - Support case-insensitive data directory lookups All language code comparisons now use lowercase for matching while preserving the original case from config for display and file paths. Tests: - Add 6 new unit tests for normalization helpers - Add integration test validating case mismatch scenario - Update existing test to reflect case-insensitive behavior - All 44 tests pass with no regressions Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
rathboma
added a commit
to rathboma/polyglot
that referenced
this pull request
Jan 21, 2026
Merges PR untra#287 fix into combined-features branch. This adds case-insensitive language code matching, allowing users to use any case variant (pt-br, pt-BR, PT-BR) and have it work correctly. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> # Conflicts: # lib/jekyll/polyglot/liquid/tags/i18n_headers.rb # lib/jekyll/polyglot/patches/jekyll/site.rb # spec/jekyll/polyglot/patches/jekyll/site_spec.rb
untra
reviewed
Jan 22, 2026
Remove lang_norm_map, languages_normalized, normalize_lang(), and lang_exists?() in favor of inline .downcase comparisons. Revert coordinate.rb and i18n_headers.rb to original logic since doc lang is now normalized at the coordinate_documents level. Simplify tests.
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
Fixes case-sensitivity bug where documents with language codes in different cases (e.g.,
lang: pt-br) were not processed when config had different casing (e.g.,languages: ['pt-BR']).Problem
Users experienced:
_site/pt-BR/but canonical URLs using/pt-br/Solution
Uses simple inline
.downcasecomparisons at the point of matching — no extra data structures or helper methods. When a document'slangfrom frontmatter or path matches a config language case-insensitively, it's normalized to the config case.Changes
site.rb:derive_lang_from_path()andcoordinate_documents()use inline.downcaseto find the matching config languageNo changes to
coordinate.rbori18n_headers.rb— normalization happens upstream incoordinate_documents.Testing
Backward Compatibility
No breaking changes — existing sites with consistent casing work exactly as before.