Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Refactor: shared locale data module for all locale-aware components

Đang mở
#23 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
40/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
react, tailwindcss, typescript

Hướng nghiên cứu

Start by comparing the locale tables in src/registry/components/language-switcher.tsx and src/registry/components/navbar.tsx to see where their coverage and lookup rules differ. Then check src/registry/registry.ts to see how a new registry entry is declared. The work is done when the new src/registry/components/locale-data.ts exports the helpers, both components use it instead of their own tables, and the locale-data unit tests and existing component tests pass.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement infrastructure priority: medium

Refactor: shared locale data module

LanguageSwitcher and NavBar each carry their own copy of locale display data:

  • language-switcher.tsx — LANG_TO_FLAG, LANG_NAMES, RTL_LOCALES (~90 languages)
  • navbar.tsx — LOCALE_MAP (~35 languages, label + flag only, no RTL)

The two have drifted (different coverage, different lookup rules), and every new locale-aware component (pill switcher, locale picker, RTL wrapper) will need the same data.

Proposal
  • Add src/registry/components/locale-data.ts exporting getLocaleLabel(code, mode), getLocaleFlag(code), isRtlLocale(code) and a resolveLocale(locale: Locale) helper that applies label / flag / rtl overrides.
  • Fall back to Intl.DisplayNames for languages not in the built-in table instead of returning the raw code.
  • Register it in src/registry/registry.ts (e.g. locale-data) so shadcn installs pull it in as a registryDependency.
  • Migrate LanguageSwitcher and NavBar to it; delete the duplicate tables.
Acceptance
  • No locale table left inside individual components
  • Unit tests for locale-data.ts (overrides, region subtags, unknown codes, RTL)
  • Existing component tests still pass

See ARCHITECTURE.md.

Ngôn ngữ chính
TypeScript
Star
39
Fork
16
Merge trung bình
2 ngày 12 giờ
Pull request đã merge (30 ngày)
10

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của babelize/babelize-elements

Tất cả issue của babelize/babelize-elements

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.