Skip to content

v0.5.5

Choose a tag to compare

@cmj0121 cmj0121 released this 05 May 13:50
· 58 commits to main since this release

Highlights

  • CF-IPCountry now decides the default locale on bare URLs — a TW visitor on an English-UI browser was sending Accept-Language: en-US,en;q=0.9, the CLDR matcher locked it to en with high confidence, and CF-IPCountry: TW never got reached. Visitors saw the English surface even though the deployment is TW-market focused. v0.5.4 only fixed the explicit ?lang=zh override path; this release fixes the default-detection path.

    Resolution chain is now ?lang=CF-IPCountryen. Accept-Language is no longer consulted. Trade-off: a Japanese tourist on a TW IP gets zh-TW unless they say ?lang=en — accepted in exchange for the local audience getting the right script by default.

Behavior delta

Visitor Before v0.5.5 After v0.5.5
TW IP, Accept-Language: en-US,en;q=0.9, bare URL en (the bug) zh-TW
TW IP, Accept-Language: zh-TW, bare URL zh-TW zh-TW
US IP, Accept-Language: zh-TW, bare URL zh-TW en
Any visitor, ?lang=… override unchanged unchanged

Other changes

  • LocaleDetector no longer appends Vary: Accept-Language to responses, removing CDN edge-cache fragmentation by raw Accept-Language value.
  • Removed dead code from internal/i18n/i18n.go: matchAcceptLanguage, matcherTags/matcherIndexToLocale/matcher, AcceptLanguageInfluenced, alInfluencedKey, headerVary/headerAcceptLanguage, and the golang.org/x/text/language import.
  • internal/i18n/i18n_test.go rewritten to pin the new contract: AL alone → en; AL + CF-IPCountry: TWzh-TW; Vary: Accept-Language is never emitted.
  • docs/localization.md updated: 3-step negotiation table, new "Why Accept-Language is not consulted" subsection, removed Cloudflare-normalization advice (no longer relevant).

Container image

ghcr.io/cmj0121/imagelet:0.5.5