-
Notifications
You must be signed in to change notification settings - Fork 430
feat(shared,ui): Add support for flattened localization usage #7656
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
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
📝 WalkthroughWalkthroughThe change adds support for nested and flattened dot-notation localization inputs. New types (LocalizationPath, FlattenedLocalizationResource, LocalizationInput) were added. Utilities isFlattenedObject, isNestedObject, validateLocalizationFormat, and unflattenObject were implemented and exported. ClerkOptions.localization type was changed from LocalizationResource to LocalizationInput. parseLocalization now validates input format, unflattens flattened inputs, and merges normalized localization into the base resource. Tests for the new types and utilities were added. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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: 1
🤖 Fix all issues with AI agents
In `@packages/shared/src/utils/unflattenObject.ts`:
- Around line 39-49: The unflattening loop currently assumes intermediate keys
are objects and will crash or overwrite when input contains conflicting keys
(e.g., "a":"x" and "a.b":"y"); update the logic inside the Object.entries loop
(the code using variables key, parts, current) to validate conflicts before
mutating: at each iteration when accessing current[part], if current[part]
exists and is not an object (typeof !== 'object' or is null) throw a descriptive
Error naming the conflicting path (e.g., the joined parts up to i) and the
original flat key; additionally, before assigning to current[parts[parts.length
- 1]] check if an existing value is an object while you're about to set a
non-object (or vice versa) and throw a similarly descriptive Error to avoid
clobbering nested structures.
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
Description
Adds support for a flattened localization object format alongside the existing nested format, allowing users to use dot-notation keys (e.g.,
"signIn.start.title") instead of nested objects.Usage
Nested format (existing):
Flattened format (new):
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
New Features
Library
Tests
✏️ Tip: You can customize this high-level summary in your review settings.