feat(locales): add RTL language support infrastructure#551
feat(locales): add RTL language support infrastructure#551ascorbic merged 12 commits intoemdash-cms:mainfrom
Conversation
Analysis of messages.po~ The backup file is outdated: - messages.po: 5,519 lines (159KB) - current, fully extracted - messages.po~: 749 lines (19KB) - old backup, incomplete Key differences: - The ~ file has only 749 lines vs 5,519 in the current file - The ~ file is dated Apr 14 04:14 (same timestamp, so created during the same operation)
…s to prevent drift from expected output
Introduces LocaleDirectionProvider component that manages text direction and language attributes for RTL locales like Arabic. Implementation: - LocaleDirectionProvider wraps Kumo's DirectionProvider - Syncs document.documentElement.dir and lang attributes with current locale - Integrates with useLocale hook for locale state - Properly ordered: I18nProvider → LocaleDirectionProvider Features: - Automatic direction switching (LTR ↔ RTL) on locale change - Single source of truth for locale → direction mapping - Updates both HTML lang and dir attributes (WCAG compliance) - Comprehensive test coverage with cleanup hooks Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 8892b67 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Scope checkThis PR changes 931 lines across 10 files. Large PRs are harder to review and more likely to be closed without review. If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs. See CONTRIBUTING.md for contribution guidelines. |
…/emdash into feat/i18n-dir-support
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/blocks
@emdash-cms/cloudflare
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
There was a problem hiding this comment.
Pull request overview
Adds RTL language direction plumbing to the admin UI by propagating locale direction into both the initial Astro shell (<html dir>) and the React app runtime (BaseUI/Kumo DirectionProvider), with tests to validate behavior.
Changes:
- Add
getLocaleDir()and locale metadata (dir) to driveltr/rtlselection (Arabic marked asrtl). - Set initial
lang/dirattributes inadmin.astro, and keep them synced at runtime via a newLocaleDirectionProvider. - Add tests for locale direction and ignore editor/gettext
*.po~backup files.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/astro/routes/admin.astro | Sets initial <html lang> and new dir based on resolved locale. |
| packages/admin/src/locales/locales.ts | Adds per-locale optional dir metadata; marks Arabic as RTL. |
| packages/admin/src/locales/config.ts | Introduces getLocaleDir() derived from supported locales. |
| packages/admin/src/locales/LocaleDirectionProvider.tsx | New provider syncing DirectionProvider + <html lang/dir> to locale. |
| packages/admin/src/locales/index.ts | Re-exports new locale direction utilities and provider. |
| packages/admin/src/App.tsx | Wraps admin app in LocaleDirectionProvider. |
| packages/admin/tests/lib/locales.test.ts | Adds unit tests for getLocaleDir(). |
| packages/admin/tests/locales/LocaleDirectionProvider.test.tsx | Adds provider behavior tests (initial + on locale change). |
| packages/admin/src/locales/.gitignore | Ignores *.po~ backup files under locales. |
| packages/admin/src/locales/ar/messages.po~ | Removes a tracked backup file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…es copilot's review comment)
ascorbic
left a comment
There was a problem hiding this comment.
Great work! Just a couple of comments
Updated the test for LocaleDirectionProvider to use a spy on console.error for better error handling. This change ensures that console errors are suppressed during the test execution and restored afterward, improving test reliability.
What does this PR do?
dirandlangattributes in astro entry file - admin.astro.po~(with a tilda) indicates it is a local backup of translation filesType of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runpnpm locale:extracthas been run (if applicable)AI-generated code disclosure
Screenshots / test output