@djangocfg/nextjs 2.1.304 → 2.1.308
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/index.mjs +1 -1
- package/dist/config/index.mjs.map +1 -1
- package/dist/i18n/components.d.mts +1 -1
- package/dist/i18n/components.mjs +9 -9
- package/dist/i18n/components.mjs.map +1 -1
- package/dist/i18n/routing.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
- package/src/i18n/components/LocaleSwitcher.tsx +16 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/nextjs",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.308",
|
|
4
4
|
"description": "Next.js server utilities: sitemap, health, OG images, contact forms, navigation, config",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nextjs",
|
|
@@ -143,9 +143,9 @@
|
|
|
143
143
|
"ai-docs": "tsx src/ai/cli.ts"
|
|
144
144
|
},
|
|
145
145
|
"peerDependencies": {
|
|
146
|
-
"@djangocfg/i18n": "^2.1.
|
|
147
|
-
"@djangocfg/monitor": "^2.1.
|
|
148
|
-
"@djangocfg/ui-core": "^2.1.
|
|
146
|
+
"@djangocfg/i18n": "^2.1.308",
|
|
147
|
+
"@djangocfg/monitor": "^2.1.308",
|
|
148
|
+
"@djangocfg/ui-core": "^2.1.308",
|
|
149
149
|
"next": "^16.2.2"
|
|
150
150
|
},
|
|
151
151
|
"peerDependenciesMeta": {
|
|
@@ -167,11 +167,11 @@
|
|
|
167
167
|
"serwist": "^9.2.3"
|
|
168
168
|
},
|
|
169
169
|
"devDependencies": {
|
|
170
|
-
"@djangocfg/i18n": "^2.1.
|
|
171
|
-
"@djangocfg/monitor": "^2.1.
|
|
172
|
-
"@djangocfg/ui-core": "^2.1.
|
|
173
|
-
"@djangocfg/layouts": "^2.1.
|
|
174
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
170
|
+
"@djangocfg/i18n": "^2.1.308",
|
|
171
|
+
"@djangocfg/monitor": "^2.1.308",
|
|
172
|
+
"@djangocfg/ui-core": "^2.1.308",
|
|
173
|
+
"@djangocfg/layouts": "^2.1.308",
|
|
174
|
+
"@djangocfg/typescript-config": "^2.1.308",
|
|
175
175
|
"@types/node": "^24.7.2",
|
|
176
176
|
"@types/react": "^19.1.0",
|
|
177
177
|
"@types/react-dom": "^19.1.0",
|
|
@@ -1,33 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* LocaleSwitcher Component (Smart)
|
|
3
3
|
*
|
|
4
|
-
* Wrapper around
|
|
5
|
-
*
|
|
4
|
+
* Wrapper around `@djangocfg/layouts` LocaleSwitcher with next-intl plumbing.
|
|
5
|
+
* Mounts its own `LayoutI18nProvider` so the switcher works standalone — no
|
|
6
|
+
* need to wrap the page in `<AppLayout i18n={...}>` just to render it.
|
|
6
7
|
*
|
|
7
8
|
* @example
|
|
8
9
|
* ```tsx
|
|
9
10
|
* import { LocaleSwitcher } from '@djangocfg/nextjs/i18n/components';
|
|
10
11
|
*
|
|
11
|
-
* // Basic usage (uses all locales from routing config)
|
|
12
12
|
* <LocaleSwitcher />
|
|
13
|
-
*
|
|
14
|
-
* // With custom locales
|
|
15
13
|
* <LocaleSwitcher locales={['en', 'ru']} />
|
|
16
|
-
*
|
|
17
|
-
* // With custom labels
|
|
18
|
-
* <LocaleSwitcher
|
|
19
|
-
* labels={{
|
|
20
|
-
* en: 'English',
|
|
21
|
-
* ru: 'Русский',
|
|
22
|
-
* ko: '한국어',
|
|
23
|
-
* }}
|
|
24
|
-
* />
|
|
14
|
+
* <LocaleSwitcher labels={{ en: 'English', ru: 'Русский' }} />
|
|
25
15
|
* ```
|
|
26
16
|
*/
|
|
27
17
|
|
|
28
18
|
'use client';
|
|
29
19
|
|
|
30
20
|
import {
|
|
21
|
+
LayoutI18nProvider,
|
|
31
22
|
LocaleSwitcher as BaseLocaleSwitcher,
|
|
32
23
|
type LocaleSwitcherProps as BaseLocaleSwitcherProps,
|
|
33
24
|
} from '@djangocfg/layouts';
|
|
@@ -35,26 +26,25 @@ import {
|
|
|
35
26
|
import { useLocaleSwitcher } from '../client';
|
|
36
27
|
import type { LocaleCode } from '../types';
|
|
37
28
|
|
|
38
|
-
export interface LocaleSwitcherProps
|
|
39
|
-
extends Omit<BaseLocaleSwitcherProps, 'locale' | 'locales' | 'onChange'> {
|
|
29
|
+
export interface LocaleSwitcherProps extends BaseLocaleSwitcherProps {
|
|
40
30
|
/** Available locales (defaults to all from routing config) */
|
|
41
31
|
locales?: LocaleCode[];
|
|
42
32
|
}
|
|
43
33
|
|
|
44
|
-
export function LocaleSwitcher({
|
|
45
|
-
locales: customLocales,
|
|
46
|
-
...props
|
|
47
|
-
}: LocaleSwitcherProps) {
|
|
34
|
+
export function LocaleSwitcher({ locales: customLocales, ...props }: LocaleSwitcherProps) {
|
|
48
35
|
const { locale, locales: routingLocales, changeLocale } = useLocaleSwitcher();
|
|
49
36
|
|
|
50
37
|
const availableLocales = customLocales || routingLocales;
|
|
51
38
|
|
|
52
39
|
return (
|
|
53
|
-
<
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
40
|
+
<LayoutI18nProvider
|
|
41
|
+
value={{
|
|
42
|
+
locale,
|
|
43
|
+
locales: availableLocales,
|
|
44
|
+
onLocaleChange: changeLocale,
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
<BaseLocaleSwitcher {...props} />
|
|
48
|
+
</LayoutI18nProvider>
|
|
59
49
|
);
|
|
60
50
|
}
|