-
Notifications
You must be signed in to change notification settings - Fork 160
feat: add locale display names for consistent language representation… #6561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughA new constant Changes
Sequence DiagramsequenceDiagram
actor User
participant MenuBar as MenuBar Component
participant getLanguageName as getLanguageName()
participant LOCALE_DISPLAY_NAMES as LOCALE_DISPLAY_NAMES<br/>(override map)
participant Intl as Intl.DisplayNames<br/>(fallback)
User->>MenuBar: Select language
MenuBar->>getLanguageName: getLanguageName(locale)
getLanguageName->>LOCALE_DISPLAY_NAMES: Check for override
alt Override found
LOCALE_DISPLAY_NAMES-->>getLanguageName: Custom display name
getLanguageName-->>MenuBar: Custom name
else No override
getLanguageName->>Intl: Resolve via Intl.DisplayNames
Intl-->>getLanguageName: Language name (or fallback)
getLanguageName-->>MenuBar: Display name
end
MenuBar->>User: Show language name
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
libs/ui/src/pure/MenuBar/index.tsx (1)
106-109: Simplify the type assertion.The type assertion
as keyof typeof LOCALE_DISPLAY_NAMESis unnecessary sinceLOCALE_DISPLAY_NAMESis already typed asPartial<Record<...>>, which allows direct access with any string key (returningstring | undefined). The subsequentif (override)check already handles the undefined case.Apply this diff to simplify:
- const override = LOCALE_DISPLAY_NAMES[locale as keyof typeof LOCALE_DISPLAY_NAMES] + const override = LOCALE_DISPLAY_NAMES[locale]
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
libs/common-const/src/locales.ts(1 hunks)libs/ui/src/pure/MenuBar/index.tsx(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Setup
- GitHub Check: Cypress
🔇 Additional comments (2)
libs/common-const/src/locales.ts (1)
11-17: LGTM! Clean centralization of locale display names.The new
LOCALE_DISPLAY_NAMESconstant provides a single source of truth for custom locale display names. The use ofPartial<Record<...>>appropriately allows for optional overrides while maintaining type safety.libs/ui/src/pure/MenuBar/index.tsx (1)
19-19: LGTM! Correct import for centralized locale names.
|
@fairlighteth for some reason the selector is not displayed in the preview link for me. Should some feature-flag be enabled? |
|
@shoom3301 ah yes, the flag was off on the preview (test) but I enabled it now |
shoom3301
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great
Summary
High-level description of what your changes are accomplishing
Before -> After
To Test
Background
Centralizes locale display labels so any selector uses the same wording and avoids duplicating overrides.
Summary by CodeRabbit
New Features
Enhancement
✏️ Tip: You can customize this high-level summary in your review settings.