-
-
Notifications
You must be signed in to change notification settings - Fork 335
feat: Add useExtracted (experimental)
#2080
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
# Conflicts: # packages/next-intl/.size-limit.ts # packages/next-intl/__mocks__/react.tsx # packages/next-intl/src/navigation/shared/createSharedNavigationFns.tsx # packages/next-intl/src/react-server/index.test.tsx # packages/next-intl/src/server/react-server/RequestLocale.tsx # packages/next-intl/src/server/react-server/getConfig.tsx
# Conflicts: # pnpm-lock.yaml
…rbo-config # Conflicts: # pnpm-lock.yaml
In Next.js 15.3, [Turbopack config has become stable](https://nextjs.org/blog/next-15-3#turbopack-configuration-in-nextconfigts-stable). With this fix, the new option is used in order to avoid a deprecation warning.
# Conflicts: # packages/next-intl/src/plugin/getNextConfig.tsx
…on APIs (#1922) With #959, the middleware already handled decoding of non-ASCII characters. This allows you to define localized [`pathnames`](https://next-intl.dev/docs/routing#pathnames) like so: ```tsx import {defineRouting} from 'next-intl/routing'; export const routing = defineRouting({ locales: ['en', 'ja'], defaultLocale: 'en', pathnames: { '/about': { 'de': '/über-uns' } } ``` Since Next.js automatically encodes incoming pathnames, this supports incoming requests both for decoded pathnames (e.g. `/de/über-uns`), as well as encoded ones (e.g. `/de/%C3%BCber-uns`). One piece has been missing though: Pathnames returned from [navigation APIs](https://next-intl.dev/docs/routing/navigation) should be turned into an encoded form. Now, `next-intl` handles this as well: ```tsx import {Link, getPathname} from '@/i18n/navigation'; // href="/de/%C3%BCber-uns" <Link href="/about" locale="de" /> // pathname = "/de/%C3%BCber-uns" const pathname = getPathname({href: '/about', locale: 'de'}); ``` This change brings the navigation APIs in line with [Google's recommendation to encode non-ASCII pathnames](https://developers.google.com/search/docs/crawling-indexing/url-structure).
# Conflicts: # examples/example-app-router-playground/tests/main.spec.ts
<!-- CURSOR_SUMMARY --> > [!NOTE] > Introduces an experimental message extraction pipeline (JSON/PO) with new `useExtracted`/`getExtracted` APIs, Turbopack/Webpack loaders, and an example app showcasing it. > > - **Experimental extraction**: > - Add extractor core (`src/extractor/*`): compiler, catalog manager/locales/persister, save scheduler, SWC-based message extractor, formatters (JSON/PO), utilities, and public export `next-intl/extractor`. > - New loaders: `extractor/extractionLoader` and `extractor/catalogLoader` (+ `.d.ts` shims). > - **Plugin/Config**: > - Extend plugin to wire loaders and rules for Turbopack/Webpack; add `experimental.srcPath`, `messages` and `extract` options; refactor next flags (`hasStableTurboConfig`, `isNextJs16OrHigher`). > - Adjust rollup build and type exposure; size-limit tweaks. > - **APIs**: > - React: export `useExtracted` (client/server) and server `getExtracted`; client re-exports from `use-intl/react`. > - **Examples/Tests**: > - New example `examples/example-app-router-extracted` demonstrating extraction; extensive extractor tests. > - Bump `examples/example-use-intl` to `use-intl@^4`. > - **Misc**: > - Package metadata/exports/files updates; add `@swc/core` and `@types/webpack` dev dep; remove obsolete example config. > - Tools: simplify side-effect import stripping in build script. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit db387c4. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
This is the final PR Bugbot will review for you during this billing cycle
Your free Bugbot reviews will reset on December 27
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| typeof current[key] !== 'object' || | ||
| current[key] === null | ||
| ) { | ||
| current[key] = {}; |
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.
Bug: Breaking Nested Keys Overwrite Non-Objects
The function doesn't handle the case where an intermediate key already exists with a non-object value (like a string). If current[key] is a string and the code tries to set a nested property under it, the existing string value will be overwritten with an empty object {}, causing data loss. For example, if "a" is set to "value1" and then "a.b" is set to "value2", the original "a" value will be lost. The condition should check if current[key] is already a string and either throw an error or handle the conflict appropriately.
| continue; | ||
| } | ||
|
|
||
| // Multi-line strings are not supported in entry mode |
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.
Bug: Metadata detection fails with out-of-order msgid/ msgstr
The metadata detection logic checks entry.msgid === '' when processing msgstr, but if msgstr appears before msgid in the file, entry.msgid will be undefined rather than an empty string. This causes the parser to fail to recognize metadata entries when msgstr "" appears before msgid "", despite the parser supporting flexible msgid/msgstr ordering as shown in the test suite.
→ Discussion