Skip to content

fix(locale): auto-detect CJK compact date offsets without explicit locale - #11

Open
kruschdev wants to merge 1 commit into
pascalorg:mainfrom
kruschdev:fix/cjk-compact-offset-detect
Open

kruschdev wants to merge 1 commit into
pascalorg:mainfrom
kruschdev:fix/cjk-compact-offset-detect

Conversation

@kruschdev

Copy link
Copy Markdown

Description

Fixes locale auto-detection for CJK compact date offsets (plan 031, plan 033) and wires localePacks auto-detection into parseDate and parseDateRange.

  • Previously, detectLocale([zh], '3天后') and detectLocale([ja], '3日後') fell back to English because compactOffset (unitWords + pastSuffixes/futureSuffixes) did not feed detectionWords or aliasWords, and CJK tokenization groups <unit><suffix> (天后, 日後, 週間前, 分钟后) into a single word token after the leading digits. I derived detectionWords directly from COMPACT_UNITS inside locales/zh.ts and locales/ja.ts so the data stays 100% tree-shaken in each locale pack (0 B added to ./core or lingo (full)).
  • Previously, parseDate and parseDateRange called resolveLanguageProfile(opts?.localePacks, opts?.locale) directly, defaulting omitted locale to 'en' even when localePacks was supplied. I extracted a shared makeP state helper in date/parse.ts that reuses the already-computed token scan with detectLanguageProfile whenever localePacks is provided without an explicit locale, keeping ./date (44.34 / 44.4 kB) and ./ai (19.39 / 19.4 kB) within their size budgets.

Checklist

Gates

  • bun run check green (typecheck, tests, build, size budgets, corpus gate, zero-deps gate)
  • bun run lint green (Biome via Ultracite)
  • Corpus diff is ADDITIVE (zero changes to existing corpus contracts)

API surface

  • Semver impact: patch (enables expected detectLocale, parseDate, and parseDateRange auto-detection for loaded CJK packs when locale is omitted)

Knowledge layer

  • CHANGELOG updated under [Unreleased]
  • Removed resolved item from plans/backlog.md

@vercel

vercel Bot commented Nov 22, 2026

Copy link
Copy Markdown

@kruschdev is attempting to deploy a commit to the Pascal Team on Vercel.

A member of the Team first needs to authorize it.

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