| feat(i18n): resolve text direction from the active locale Adds the plumbing that makes direction a property of the language rather than something hardcoded, plus the codemod used to convert the codebase. Direction has to be resolved on the client. i18next's highest-priority detection source is localStorage, which the server cannot read, and reading the cookie in the root layout would deopt every page to dynamic rendering and still be wrong whenever the two disagree. So dir-init.js runs synchronously in <head> and writes lang/dir before the body paints — the same approach embed-bg.js already uses to avoid a flash. Its detection order mirrors lib/i18n.ts exactly, and the RTL list it carries is asserted against lib/direction.ts by a test, since it's a constant duplicated into a file the bundler never sees. AVAILABLE_LANGUAGES gains a `dir` field, so Persian works today and a future locale is a one-line change; nothing branches on "is Arabic". useDirection() exposes it to components along with a multiplier for physical offsets, and Radix's DirectionProvider makes align="end", collision flipping and arrow-key navigation direction-aware across ~40 call sites with no per-component edits. The codemod converts physical Tailwind utilities to logical ones. It parses with the TypeScript compiler API rather than running a regex over the file, because `pr-`, `mr-` and `pl-` appear in URLs, i18n keys and identifiers. space-x-*, divide-x* and inset-x-* are skipped — they already emit logical properties in v4 — and so is any 50% inset, which is a centering idiom whose paired translate may live in a sibling class or an inline style, and which lands off-centre in RTL if converted alone. Also drops tailwind.config.js. Tailwind v4 only loads it via an @config directive this project doesn't have, so it was dead — and a trap for anyone later adding an RTL plugin there. | 1 个月前 |