Skip to content

feat(locales): add RTL language support infrastructure#551

Merged
ascorbic merged 12 commits intoemdash-cms:mainfrom
ophirbucai:feat/i18n-dir-support
Apr 14, 2026
Merged

feat(locales): add RTL language support infrastructure#551
ascorbic merged 12 commits intoemdash-cms:mainfrom
ophirbucai:feat/i18n-dir-support

Conversation

@ophirbucai
Copy link
Copy Markdown
Contributor

@ophirbucai ophirbucai commented Apr 14, 2026

What does this PR do?

  • Adds RTL languages support by setting html dir and lang attributes in astro entry file - admin.astro
  • Wraps React app with BaseUI's DirectionProvider (which @cloudflare/kumo re-exports) and syncs changes to html on locale changes
  • Sidebar mobile support slide animation via CSS overrides
  • Update .gitignore to prevent committing .po~ (with a tilda) indicates it is a local backup of translation files

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

AI-generated code disclosure

  • This PR includes AI-generated code

Screenshots / test output

Screenshot 2026-04-14 at 6 05 26
Screenshot 2026-04-14 at 6 00 03 Screenshot 2026-04-14 at 5 59 16

ophirbucai and others added 5 commits April 14, 2026 04:51
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)
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>
Copilot AI review requested due to automatic review settings April 14, 2026 03:08
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 14, 2026

🦋 Changeset detected

Latest commit: 8892b67

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@emdash-cms/admin Minor
emdash Minor
@emdash-cms/cloudflare Minor
@emdash-cms/auth Minor
@emdash-cms/blocks Minor
@emdash-cms/gutenberg-to-portable-text Minor
@emdash-cms/x402 Minor
create-emdash Minor
@emdash-cms/plugin-embeds Patch

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

@github-actions
Copy link
Copy Markdown
Contributor

Scope check

This 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.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 14, 2026

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@551

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@551

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@551

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@551

emdash

npm i https://pkg.pr.new/emdash@551

create-emdash

npm i https://pkg.pr.new/create-emdash@551

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@551

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@551

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@551

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@551

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@551

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@551

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@551

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@551

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@551

commit: 8892b67

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 drive ltr/rtl selection (Arabic marked as rtl).
  • Set initial lang/dir attributes in admin.astro, and keep them synced at runtime via a new LocaleDirectionProvider.
  • 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.

Copy link
Copy Markdown
Collaborator

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@ophirbucai ophirbucai requested a review from ascorbic April 14, 2026 07:52
Copy link
Copy Markdown
Collaborator

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ascorbic ascorbic merged commit 598026c into emdash-cms:main Apr 14, 2026
26 checks passed
@emdashbot emdashbot bot mentioned this pull request Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants