@djangocfg/nextjs 2.1.579 → 2.1.581

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.
@@ -38,6 +38,11 @@ interface I18nProviderProps {
38
38
  locale: LocaleCode;
39
39
  /** Translation messages */
40
40
  messages: Messages;
41
+ /**
42
+ * Locales the app ships. `useLocales()` / `useLocaleSwitcher()` report these;
43
+ * without it they fall back to the package's built-in list.
44
+ */
45
+ locales?: LocaleCode[];
41
46
  /** Time zone for date/time formatting */
42
47
  timeZone?: string;
43
48
  /** Now value for relative time */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/nextjs",
3
- "version": "2.1.579",
3
+ "version": "2.1.581",
4
4
  "description": "Next.js server utilities: sitemap, health, OG images, contact forms, navigation, config",
5
5
  "keywords": [
6
6
  "nextjs",
@@ -149,9 +149,9 @@
149
149
  "ai-docs": "tsx src/ai/cli.ts"
150
150
  },
151
151
  "peerDependencies": {
152
- "@djangocfg/devtools": "^2.1.579",
153
- "@djangocfg/i18n": "^2.1.579",
154
- "@djangocfg/ui-core": "^2.1.579",
152
+ "@djangocfg/devtools": "^2.1.581",
153
+ "@djangocfg/i18n": "^2.1.581",
154
+ "@djangocfg/ui-core": "^2.1.581",
155
155
  "next": "^16.2.2"
156
156
  },
157
157
  "peerDependenciesMeta": {
@@ -170,11 +170,11 @@
170
170
  "semver": "^7.8.5"
171
171
  },
172
172
  "devDependencies": {
173
- "@djangocfg/devtools": "^2.1.579",
174
- "@djangocfg/i18n": "^2.1.579",
175
- "@djangocfg/layouts": "^2.1.579",
176
- "@djangocfg/typescript-config": "^2.1.579",
177
- "@djangocfg/ui-core": "^2.1.579",
173
+ "@djangocfg/devtools": "^2.1.581",
174
+ "@djangocfg/i18n": "^2.1.581",
175
+ "@djangocfg/layouts": "^2.1.581",
176
+ "@djangocfg/typescript-config": "^2.1.581",
177
+ "@djangocfg/ui-core": "^2.1.581",
178
178
  "@types/node": "^25.9.5",
179
179
  "@types/react": "19.2.15",
180
180
  "@types/react-dom": "19.2.3",
@@ -53,6 +53,7 @@ export const DEFAULT_TRANSPILE_PACKAGES = [
53
53
  '@djangocfg/widget-forms',
54
54
  '@djangocfg/widget-kit',
55
55
  '@djangocfg/widget-map',
56
+ '@djangocfg/widget-mcp',
56
57
  '@djangocfg/widget-media',
57
58
  '@djangocfg/widget-ogimage',
58
59
  '@djangocfg/widget-overlay',
@@ -26,7 +26,7 @@ import {
26
26
  } from 'next-intl';
27
27
 
28
28
  import { usePathname } from './navigation';
29
- import { I18nProvider, NextIntlProvider } from './provider';
29
+ import { I18nProvider, NextIntlProvider, useDeclaredLocales } from './provider';
30
30
  import { routing } from './routing';
31
31
 
32
32
  // Re-export providers
@@ -161,7 +161,8 @@ export function useRelativeTimeFormatter() {
161
161
  // ─────────────────────────────────────────────────────────────────────────────
162
162
 
163
163
  /**
164
- * Get list of available locales from routing config
164
+ * Locales the app declared on `I18nProvider`; the built-in routing list only
165
+ * when it declared none.
165
166
  *
166
167
  * @example
167
168
  * ```tsx
@@ -170,7 +171,8 @@ export function useRelativeTimeFormatter() {
170
171
  * ```
171
172
  */
172
173
  export function useLocales(): LocaleCode[] {
173
- return routing.locales as LocaleCode[];
174
+ const declared = useDeclaredLocales();
175
+ return declared ?? (routing.locales as LocaleCode[]);
174
176
  }
175
177
 
176
178
  /**
@@ -25,10 +25,16 @@
25
25
 
26
26
  'use client';
27
27
 
28
+ import { createContext, useContext } from 'react';
28
29
  import { NextIntlClientProvider } from 'next-intl';
29
30
  import { I18nProvider as DjangoCfgI18nProvider } from '@djangocfg/i18n';
30
31
  import type { I18nProviderProps, LocaleCode } from './types';
31
32
 
33
+ const DeclaredLocalesContext = createContext<LocaleCode[] | null>(null);
34
+
35
+ /** Locales the app passed to its provider, or null when it passed none. */
36
+ export const useDeclaredLocales = (): LocaleCode[] | null => useContext(DeclaredLocalesContext);
37
+
32
38
  // ─────────────────────────────────────────────────────────────────────────────
33
39
  // Provider Component
34
40
  // ─────────────────────────────────────────────────────────────────────────────
@@ -42,6 +48,7 @@ import type { I18nProviderProps, LocaleCode } from './types';
42
48
  export function I18nProvider({
43
49
  locale,
44
50
  messages,
51
+ locales,
45
52
  timeZone = 'UTC',
46
53
  now,
47
54
  children,
@@ -57,7 +64,9 @@ export function I18nProvider({
57
64
  locale={locale as LocaleCode}
58
65
  translations={messages}
59
66
  >
60
- {children}
67
+ <DeclaredLocalesContext.Provider value={locales ?? null}>
68
+ {children}
69
+ </DeclaredLocalesContext.Provider>
61
70
  </DjangoCfgI18nProvider>
62
71
  </NextIntlClientProvider>
63
72
  );
@@ -74,6 +83,7 @@ export function I18nProvider({
74
83
  export function NextIntlProvider({
75
84
  locale,
76
85
  messages,
86
+ locales,
77
87
  timeZone = 'UTC',
78
88
  now,
79
89
  children,
@@ -85,7 +95,9 @@ export function NextIntlProvider({
85
95
  timeZone={timeZone}
86
96
  now={now}
87
97
  >
88
- {children}
98
+ <DeclaredLocalesContext.Provider value={locales ?? null}>
99
+ {children}
100
+ </DeclaredLocalesContext.Provider>
89
101
  </NextIntlClientProvider>
90
102
  );
91
103
  }
package/src/i18n/types.ts CHANGED
@@ -55,6 +55,11 @@ export interface I18nProviderProps {
55
55
  locale: LocaleCode;
56
56
  /** Translation messages */
57
57
  messages: Messages;
58
+ /**
59
+ * Locales the app ships. `useLocales()` / `useLocaleSwitcher()` report these;
60
+ * without it they fall back to the package's built-in list.
61
+ */
62
+ locales?: LocaleCode[];
58
63
  /** Time zone for date/time formatting */
59
64
  timeZone?: string;
60
65
  /** Now value for relative time */