-
-
Notifications
You must be signed in to change notification settings - Fork 342
feat: Custom formats for useExtracted, consistency fixes for file references, pruning of messages and sorting of keys
#2155
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).
…ly in `POCodecSourceMessageKey` (#2163)
@ceolinwill Ah yep, that's a great point! I've also discovered that namespaces were not supported by the custom PO codec. I've now fixed both of these bugs in #2163. This also required a change in
Could you give this another go? If this looks fine to you, I can publish My comment above about |
@amannn Great idea. The formatting issues I had before are gone. Running In my custom codec I’d likely invert that: keep the id in
If the source message were placed in I did notice a potential new issue but I'm not sure:
Not sure yet if this is a real bug because I couldn't reproduce it again. I didn’t clear |
|
@ceolinwill Thanks for the feedback!
Nice! 👍
Yeah, that's surely fine too! The PO "spec" has some hints here:
Many i18n libs like
Thanks! I also tried reproducing it in a project and investigated a bit, but no luck so far. If you encounter it again, definitely let me know—thanks! |
…2166) Co-authored-by: Cursor Agent <cursoragent@cursor.com>
|
@ceolinwill I've updated this PR with a few fixes, some of them quite significant. It's only internal changes though. This PR now also includes fixes for file references to be consistently updated and messages pruned when no longer used (both for builds as well as dev). Clearing Would you mind giving this a quick sanity check in your app? That would be really helpful 🙏 Hopefully I can finally release to stable then, including the new feature for custom formats. |
useExtracteduseExtracted and consistency fixes for file references
useExtracted and consistency fixes for file referencesuseExtracted and consistency fixes for file references & pruning of messages
useExtracted and consistency fixes for file references & pruning of messagesuseExtracted, consistency fixes for file references and pruning of messages
|
@amannn Just tested it and everything looks great
One promising note: In this monorepo, I upgraded only one app to the new version and left another on the old version. When I ran Great job! |
|
Nice, that's really good to hear! Ok, let's get this over the finish line then … |
useExtracted, consistency fixes for file references and pruning of messagesuseExtracted, consistency fixes for file references, pruning of messages and sorting of keys
Notes
useExtracted: Custom formatcodecs(see also thefixtures)next-intl@0.0.0-canary-6876534Changes
useExtracted#2158useExtracted#2154POCodecSourceMessageKey#2163useExtractedafter renames / deletions #2166useExtracted(during build) #2169useExtracted(duringdev) #2170Note
Introduces codec-based message formats (built-in JSON/PO + custom), overhauls the
useExtractedpipeline with file watching, consistent reference handling and pruning, and updates docs, tests, plugin loaders, examples, workflows, and dependencies.defineCodec) with built-injson/pocodecs and support for custom formats; expose vianext-intl/extractor.extractAll,CatalogManagerimprovements (metadata merge, reference dedupe/sort, pruning obsolete messages), robust error handling, and source watching via@parcel/watcher.extractionLoader,catalogLoader) and format resolution (getFormatExtension,resolveCodec).SourceFileWatcher.useExtracteddocs with Formats section (JSON/PO/Custom) and examples; minor plugin/config wording tweaks.Client→Counter; increase Playwright retries on CI.chunkFileNamesin Rollup.@parcel/watcher; bumppo-parserto v2; update Lerna and conventional-changelog packages.Written by Cursor Bugbot for commit d43359c. This will update automatically on new commits. Configure here.