Skip to content

fix: Improvements for useExtracted#2176

Merged
amannn merged 146 commits intomainfrom
canary
Dec 16, 2025
Merged

fix: Improvements for useExtracted#2176
amannn merged 146 commits intomainfrom
canary

Conversation

@amannn
Copy link
Owner

@amannn amannn commented Dec 15, 2025

# 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
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).
@vercel
Copy link

vercel bot commented Dec 15, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
next-intl-docs Ready Ready Preview, Comment Dec 16, 2025 4:16pm
next-intl-example-app-router Ready Ready Preview, Comment Dec 16, 2025 4:16pm
next-intl-example-app-router-without-i18n-routing Ready Ready Preview, Comment Dec 16, 2025 4:16pm

@amannn
Copy link
Owner Author

amannn commented Dec 16, 2025

@cursoragent review this pr

@cursor
Copy link

cursor bot commented Dec 16, 2025

The PR consolidates several improvements and fixes for useExtracted, focusing on stability, correctness during file system events, and code cleanup.

Key Changes Reviewed

  • Concurrency & Race Conditions:

    • Introduced scanCompletePromise in CatalogManager to ensure the initial project scan finishes before any file watcher events are processed. This prevents race conditions where watcher events could interfere with the initial extraction.
    • Verified by the test case: avoids race condition when watcher processes files during initial scan.
  • Folder Operations:

    • SourceFileWatcher now correctly handles directory events.
    • Directory Creation: Automatically scans and emits events for all source files within a newly created directory (normalizeEvents).
    • Directory Deletion: Expands directory delete events into individual delete events for all known files within that directory (expandDirectoryDeleteEvents). This ensures messages are correctly removed when their parent folder is deleted.
    • Verified by tests in describe('folder operations', ...) .
  • Error Handling:

    • CatalogManager.processFile now gracefully handles extraction errors (e.g., syntax errors in source files). Instead of crashing or throwing, it returns false, effectively ignoring the invalid file until it is fixed.
    • Verified by tests: omits file with parse error... and ignores parse error from watcher....
  • Cleanup:

    • Removed Logger and associated logging calls across MessageExtractor, CatalogManager, and ExtractionCompiler. This simplifies the code and reduces noise.

Conclusion

The changes are robust and well-covered by new test cases in ExtractionCompiler.test.tsx. The implementation of scanCompletePromise and the enhanced SourceFileWatcher logic correctly address the issues regarding inconsistent state and folder handling.

@amannn The changes look good and ready to merge.

<todo_list>
</todo_list>


Open in Cursor Open in Web

Learn more about Cursor Agents

@cursor
Copy link

cursor bot commented Dec 16, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@amannn amannn marked this pull request as ready for review December 16, 2025 16:25
@amannn amannn merged commit 3937e44 into main Dec 16, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants