Skip to content

Stop baking language redirects into the dataset - #22

Merged
in-c0 merged 1 commit into
mainfrom
fix/locale-redirects
Aug 28, 2026
Merged

Stop baking language redirects into the dataset#22
in-c0 merged 1 commit into
mainfrom
fix/locale-redirects

Conversation

@in-c0

@in-c0 in-c0 commented Aug 28, 2026

Copy link
Copy Markdown
Owner

The first automated freshness PR (#21) surfaced a regression I introduced in #17.

-Google Analytics API,https://developers.google.com/analytics,...
+Google Analytics API,https://developers.google.com/analytics?hl=zh-cn,...

Google's documentation redirects to whichever locale it infers from the client. The checker followed that redirect and recorded the destination as canonical — so a --fix pass pinned rows of an English dataset to whatever language the runner happened to look like.

212 URLs were affected. Zero carried a locale parameter before #17, so this is mine, not inherited. ?hl=pt-br (39), ?hl=ar (34), ?hl=he, ?hl=zh-cn, ?hl=bn, and a dozen more. #21 was about to add six more and is closed in favour of this.

Fix

  • Requests send Accept-Language: en-US,en;q=0.9, so the redirect mostly stops happening.
  • normalise() drops language-selection parameters (hl, lang, locale, setlang, ui_locales), so a redirect that only picks a translation classifies as ok and never generates a correction.
  • A genuine move that lands on a localised URL is still moved, with the language stripped before it is written.
  • --fix also cleans locale parameters an earlier pass baked in: 212 stripped, zero remaining.

Worth flagging in the numbers

moved drops from 41.7% at the baseline to 0.1%. Some of that fall is the redirect repair genuinely working — but part of the original 41.7% was this bug counting translations as moves, so the baseline overstated drift. The ok rate is now 93.9%.

npm test → 31 passing, including a case asserting that a real move carrying a locale is still detected as a move.

🤖 Generated with Claude Code

Google's documentation redirects to whichever locale it infers from the client.
The checker followed those redirects and recorded the destination as canonical,
so a --fix pass pinned English rows to whatever language the runner looked like
that day: 212 URLs across the dataset carried ?hl=pt-br, ?hl=ar, ?hl=he and
similar. None were there before #17 — this was my regression, and the first
automated PR (#21) was about to add six more.

Two changes. Requests now send Accept-Language: en-US,en;q=0.9, so the redirect
mostly does not happen. And normalise() drops language-selection parameters, so a
redirect that only picks a translation classifies as `ok` rather than `moved` and
never produces a correction. A genuine move that happens to land on a localised
URL still counts as moved, with the language stripped before it is written.

--fix now also strips language parameters an earlier pass baked in: 212 cleaned,
zero remaining.

Side effect worth noting: `moved` drops from 41.7% at the baseline to 0.1%. Some
of that fall was the redirect repair working, but part of the original figure was
this bug counting translations as moves.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@in-c0
in-c0 merged commit 6468f86 into main Aug 28, 2026
2 checks passed
@in-c0
in-c0 deleted the fix/locale-redirects branch August 28, 2026 02:32
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