feat(compiler): add useLocale hook and setLocale/getLocale functions#1964
Conversation
- Add useLocale() hook for reactive locale access in components - Add setLocale() function for changing locale from anywhere - Add getLocale() function for non-reactive locale access - Add Next.js version compatibility warning for < 15 - Update README documentation with React Client API section Closes #1696 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughUpdated React Client API documentation for the new-compiler package: renamed Changes
Sequence Diagram(s)(omitted — changes are documentation and API-surface examples only) Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 4❌ Failed checks (3 warnings, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
7fd16e0 to
068fd8a
Compare
- Add useLocale() hook for reactive locale access in components - Add setLocale() function for changing locale from anywhere - Add getLocale() function for non-reactive locale access - Update README documentation with React Client API section Closes #1696 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
068fd8a to
6e004b4
Compare
- Rename test to reflect new behavior of skipping keys not present in the original input. - Adjust expected result to match the updated logic in the loader function. - Remove unnecessary key reordering logic from the loader implementation.
- Update README with useLingoContext() usage for locale switching
- Remove unused useLocale/setLocale code in favor of useLingoContext()
- Users can use useLingoContext() to get { locale, setLocale }
Closes #1696
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/new-compiler/src/react/README.md`:
- Around line 101-104: Update the README text in the `useLingoContext()` section
to hyphenate "locale-switching" for grammar consistency by changing the sentence
to read "Use this for custom locale-switching components." so the
`useLingoContext()` description contains the corrected phrase.
🧹 Nitpick comments (1)
packages/new-compiler/README.md (1)
339-346: Document the full client API surface for parity.This section omits
registerHashes(listed in the react README) and does not mention the standalonegetLocale()/setLocale()helpers described in the PR objectives. Consider adding them here to keep the docs consistent.
Summary
useLocale()hook for reactive locale access in React componentssetLocale()function for changing locale from anywhere (event handlers, callbacks, etc.)getLocale()function for non-reactive locale accessNew API
Test plan
Closes #1696
🤖 Generated with Claude Code
Summary by CodeRabbit
Documentation
API Updates
New Features