Skip to content

Commit 951c8eb

Browse files
ericyangpanclaude
andcommitted
feat(i18n): add navigation utilities for internationalization
- Create navigation.ts with i18n-aware routing configuration - Export localized Link, redirect, usePathname, useRouter, and getPathname - Configure locale prefix as 'as-needed' for cleaner URLs - Leverage next-intl/navigation for automatic locale handling 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent d6bce5a commit 951c8eb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/i18n/navigation.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { createNavigation } from 'next-intl/navigation';
2+
import { defineRouting } from 'next-intl/routing';
3+
import { locales, defaultLocale } from './config';
4+
5+
export const routing = defineRouting({
6+
locales,
7+
defaultLocale,
8+
localePrefix: 'as-needed',
9+
});
10+
11+
// Create localized versions of Link, redirect, usePathname, useRouter, getPathname
12+
// These will automatically handle locale prefixes based on the current locale
13+
export const { Link, redirect, usePathname, useRouter, getPathname } =
14+
createNavigation(routing);

0 commit comments

Comments
 (0)