@intlayer/next-intl 9.5.3 → 9.5.4-canary.0
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/README.md +8 -8
- package/dist/cjs/client/NextIntlClientProvider.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/navigation/Link.cjs +1 -1
- package/dist/cjs/navigation/createNavigation.cjs +1 -1
- package/dist/cjs/navigation/hooks.cjs +1 -1
- package/dist/cjs/navigation/index.cjs +1 -1
- package/dist/cjs/plugin/index.cjs +1 -1
- package/dist/cjs/server/index.cjs +5 -5
- package/dist/cjs/server/react/index.cjs +3 -3
- package/dist/esm/client/NextIntlClientProvider.mjs +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/navigation/Link.mjs +1 -1
- package/dist/esm/navigation/createNavigation.mjs +1 -1
- package/dist/esm/navigation/hooks.mjs +1 -1
- package/dist/esm/navigation/index.mjs +1 -1
- package/dist/esm/plugin/index.mjs +1 -1
- package/dist/esm/server/index.mjs +5 -5
- package/dist/esm/server/react/index.mjs +3 -3
- package/package.json +12 -11
- package/dist/cjs/react-server/helpers.cjs +0 -20
- package/dist/cjs/react-server/helpers.cjs.map +0 -1
- package/dist/cjs/react-server/index.cjs +0 -61
- package/dist/cjs/react-server/resolveLocale.cjs +0 -19
- package/dist/cjs/react-server/resolveLocale.cjs.map +0 -1
- package/dist/cjs/react-server/useDictionary.cjs +0 -23
- package/dist/cjs/react-server/useDictionary.cjs.map +0 -1
- package/dist/cjs/react-server/useDictionaryDynamic.cjs +0 -19
- package/dist/cjs/react-server/useDictionaryDynamic.cjs.map +0 -1
- package/dist/cjs/react-server/useLocale.cjs +0 -13
- package/dist/cjs/react-server/useLocale.cjs.map +0 -1
- package/dist/cjs/react-server/useTranslations.cjs +0 -42
- package/dist/cjs/react-server/useTranslations.cjs.map +0 -1
- package/dist/cjs/warnUnsupported.cjs +0 -28
- package/dist/cjs/warnUnsupported.cjs.map +0 -1
- package/dist/esm/react-server/helpers.mjs +0 -17
- package/dist/esm/react-server/helpers.mjs.map +0 -1
- package/dist/esm/react-server/index.mjs +0 -10
- package/dist/esm/react-server/resolveLocale.mjs +0 -18
- package/dist/esm/react-server/resolveLocale.mjs.map +0 -1
- package/dist/esm/react-server/useDictionary.mjs +0 -22
- package/dist/esm/react-server/useDictionary.mjs.map +0 -1
- package/dist/esm/react-server/useDictionaryDynamic.mjs +0 -18
- package/dist/esm/react-server/useDictionaryDynamic.mjs.map +0 -1
- package/dist/esm/react-server/useLocale.mjs +0 -12
- package/dist/esm/react-server/useLocale.mjs.map +0 -1
- package/dist/esm/react-server/useTranslations.mjs +0 -41
- package/dist/esm/react-server/useTranslations.mjs.map +0 -1
- package/dist/esm/warnUnsupported.mjs +0 -27
- package/dist/esm/warnUnsupported.mjs.map +0 -1
- package/dist/types/react-server/helpers.d.ts +0 -12
- package/dist/types/react-server/helpers.d.ts.map +0 -1
- package/dist/types/react-server/index.d.ts +0 -9
- package/dist/types/react-server/resolveLocale.d.ts +0 -14
- package/dist/types/react-server/resolveLocale.d.ts.map +0 -1
- package/dist/types/react-server/useDictionary.d.ts +0 -24
- package/dist/types/react-server/useDictionary.d.ts.map +0 -1
- package/dist/types/react-server/useDictionaryDynamic.d.ts +0 -15
- package/dist/types/react-server/useDictionaryDynamic.d.ts.map +0 -1
- package/dist/types/react-server/useLocale.d.ts +0 -9
- package/dist/types/react-server/useLocale.d.ts.map +0 -1
- package/dist/types/react-server/useTranslations.d.ts +0 -23
- package/dist/types/react-server/useTranslations.d.ts.map +0 -1
- package/dist/types/warnUnsupported.d.ts +0 -18
- package/dist/types/warnUnsupported.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<a href="https://intlayer.org" rel="">
|
|
3
|
-
<img src="https://raw.githubusercontent.com/aymericzip/intlayer/main/docs/assets/cover.
|
|
3
|
+
<img src="https://raw.githubusercontent.com/aymericzip/intlayer/main/docs/assets/cover.webp" width="60%" alt="Intlayer Logo" />
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
@@ -49,10 +49,10 @@ With **per-locale content files**, **TypeScript autocompletion**, **tree-shakabl
|
|
|
49
49
|
|
|
50
50
|
| Feature | Description |
|
|
51
51
|
| --------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
52
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.
|
|
52
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.webp?raw=true" alt="Feature" width="700"> | **Cross-Frameworks Support**<br><br>Intlayer is compatible with all major frameworks and libraries, including Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, and more. |
|
|
53
53
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.jpg?raw=true" alt="Feature" width="700"> | **JavaScript-Powered Content Management**<br><br>Harness the flexibility of JavaScript to define and manage your content efficiently. <br><br> - [Content declaration](https://intlayer.org/doc/concept/content) |
|
|
54
54
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/per_locale_content_declaration_file.png?raw=true" alt="Feature" width="700"> | **Per-Locale Content Declaration File**<br><br>Speed up your development by declaring your content once, before auto generation.<br><br> - [Per-Locale Content Declaration File](https://intlayer.org/doc/concept/per-locale-file) |
|
|
55
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/compiler.
|
|
55
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/compiler.webp?raw=true" alt="Feature" width="700"> | **Compiler**<br><br>The Intlayer Compiler extract automatically the content from the components and generate the dictionary files.<br><br> - [Compiler](https://intlayer.org/doc/compiler) |
|
|
56
56
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true" alt="Feature" width="700"> | **Type-Safe Environment**<br><br>Leverage TypeScript to ensure your content definitions and code are error-free, while also benefiting from IDE autocompletion.<br><br> - [TypeScript configuration](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
|
|
57
57
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/config_file.png?raw=true" alt="Feature" width="700"> | **Simplified Setup**<br><br>Get up and running quickly with minimal configuration. Adjust settings for internationalization, routing, AI, build, and content handling with ease. <br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
|
|
58
58
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/content_retrieval.png?raw=true" alt="Feature" width="700"> | **Simplified Content Retrieval**<br><br>No need to call your `t` function for each piece of content. Retrieve all your content directly using a single hook.<br><br> - [React integration](https://intlayer.org/doc/environment/create-react-app) |
|
|
@@ -60,12 +60,12 @@ With **per-locale content files**, **TypeScript autocompletion**, **tree-shakabl
|
|
|
60
60
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/file_tree.png?raw=true" alt="Feature" width="700"> | **Organized Codebase**<br><br>Keep your codebase more organized: 1 component = 1 dictionary in the same folder. Translations close to their respective components, enhance maintainability and clarity. <br><br> - [How Intlayer works](https://intlayer.org/doc/concept/how-works-intlayer) |
|
|
61
61
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/url_routing.png?raw=true" alt="Feature" width="700"> | **Enhanced Routing**<br><br>Full support of app routing, adapting seamlessly to complex application structures, for Next.js, React, Vite, Vue.js, etc.<br><br> - [Explore Next.js integration](https://intlayer.org/doc/environment/nextjs) |
|
|
62
62
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/markdown.png?raw=true" alt="Feature" width="700"> | **Markdown Support**<br><br>Import and interpret, locale files and remote Markdown for multilingual content like privacy policies, documentation, etc. Interpret and make Markdown metadata accessible in your code.<br><br> - [Content files](https://intlayer.org/doc/concept/content/file) |
|
|
63
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/visual_editor.
|
|
64
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/bundle.
|
|
65
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/static_rendering.
|
|
63
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/visual_editor.webp?raw=true" alt="Feature" width="700"> | **Free Visual Editor & CMS**<br><br>A free visual editor and CMS are available for content writers, removing the need for a localization platform. Keep your content synchronized using Git, or externalize it totally or partially with the CMS.<br><br> - [Intlayer Editor](https://intlayer.org/doc/concept/editor) <br> - [Intlayer CMS](https://intlayer.org/doc/concept/cms) |
|
|
64
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/bundle.webp?raw=true" alt="Feature" width="700"> | **Tree-shakable Content**<br><br>Tree-shakable content, reducing the size of the final bundle. Loads content per component, excluding any unused content from your bundle. Supports lazy loading to enhance app loading efficiency. <br><br> - [App build optimization](https://intlayer.org/doc/concept/how-works-intlayer#app-build-optimization) |
|
|
65
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/static_rendering.webp?raw=true" alt="Feature" width="700"> | **Static Rendering**<br><br>Doesn't block Static Rendering. <br><br> - [Next.js integration](https://intlayer.org/doc/environment/nextjs) |
|
|
66
66
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/AI_translation.png?raw=true" alt="Feature" width="700"> | **AI-Powered Translation**<br><br>Transform your website into 231 languages with just one click using Intlayer's advanced AI-powered translation tools using your own AI provider / API key. <br><br> - [CI/CD integration](https://intlayer.org/doc/concept/ci-cd) <br> - [Intlayer CLI](https://intlayer.org/doc/concept/cli) <br> - [Auto fill](https://intlayer.org/doc/concept/auto-fill) |
|
|
67
67
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/mcp.png?raw=true" alt="Feature" width="700"> | **MCP Server Integration**<br><br>Provides an MCP (Model Context Protocol) server for IDE automation, enabling seamless content management and i18n workflows directly within your development environment. <br><br> - [MCP Server](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/mcp_server.md) |
|
|
68
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/vscode_extension.
|
|
68
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/vscode_extension.webp?raw=true" alt="Feature" width="700"> | **VSCode Extension**<br><br>Intlayer provides a VSCode extension to help you manage your content and translations, building your dictionaries, translating your content, and more. <br><br> - [VSCode Extension](https://intlayer.org/doc/vs-code-extension) |
|
|
69
69
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/interoperability.png?raw=true" alt="Feature" width="700"> | **Interoperability**<br><br>Allow interoperability with react-i18next, next-i18next, next-intl, react-intl, vue-i18n. <br><br> - [Intlayer and react-intl](https://intlayer.org/blog/intlayer-with-react-intl) <br> - [Intlayer and next-intl](https://intlayer.org/blog/intlayer-with-next-intl) <br> - [Intlayer and next-i18next](https://intlayer.org/blog/intlayer-with-next-i18next) <br> - [Intlayer and vue-i18n](https://intlayer.org/blog/intlayer-with-vue-i18n) <br> - [Intlayer compat adapters](https://intlayer.org/doc/compatibility) |
|
|
70
70
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/benchmark.png?raw=true" alt="Feature" width="700"> | **Performances & Benchmark**<br><br>Uses advanced tree-shaking and dynamic loading to boost performances and keep the solution as light as possible. <br><br> - [Performances & Benchmark](https://intlayer.org/doc/benchmark) |
|
|
71
71
|
|
|
@@ -262,7 +262,7 @@ Intlayer connects **developers**, **copywriters**, and **AI agents** in one work
|
|
|
262
262
|
- Feature flags
|
|
263
263
|
- Headless CMSs (e.g. Contentful, Strapi, Sanity)
|
|
264
264
|
|
|
265
|
-

|
|
266
266
|
|
|
267
267
|
## 🌐 Readme in other languages
|
|
268
268
|
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
5
|
-
let next_intlayer = require("next-intlayer");
|
|
6
5
|
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
7
6
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
8
7
|
let _intlayer_core_localization = require("@intlayer/core/localization");
|
|
9
8
|
let next_navigation = require("next/navigation");
|
|
9
|
+
let next_intlayer = require("next-intlayer");
|
|
10
10
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
11
|
|
|
12
12
|
//#region src/client/NextIntlClientProvider.tsx
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_routing = require('./routing.cjs');
|
|
3
2
|
const require_client_NextIntlClientProvider = require('./client/NextIntlClientProvider.cjs');
|
|
4
3
|
const require_client_useLocale = require('./client/useLocale.cjs');
|
|
4
|
+
const require_routing = require('./routing.cjs');
|
|
5
5
|
let _intlayer_use_intl = require("@intlayer/use-intl");
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, 'IntlError', {
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
4
4
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
5
5
|
const require_navigation_localizeHref = require('./localizeHref.cjs');
|
|
6
6
|
let next_intlayer = require("next-intlayer");
|
|
7
|
-
let react = require("react");
|
|
8
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
let react = require("react");
|
|
9
9
|
let next_link = require("next/link");
|
|
10
10
|
next_link = require_runtime.__toESM(next_link);
|
|
11
11
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
2
|
const require_navigation_localizeHref = require('./localizeHref.cjs');
|
|
3
|
-
const require_navigation_Link = require('./Link.cjs');
|
|
4
3
|
const require_navigation_hooks = require('./hooks.cjs');
|
|
4
|
+
const require_navigation_Link = require('./Link.cjs');
|
|
5
5
|
let next_navigation = require("next/navigation");
|
|
6
6
|
|
|
7
7
|
//#region src/navigation/createNavigation.ts
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
const require_navigation_localizeHref = require('./localizeHref.cjs');
|
|
5
|
-
let next_intlayer = require("next-intlayer");
|
|
6
5
|
let next_navigation = require("next/navigation");
|
|
6
|
+
let next_intlayer = require("next-intlayer");
|
|
7
7
|
|
|
8
8
|
//#region src/navigation/hooks.ts
|
|
9
9
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
-
const require_navigation_Link = require('./Link.cjs');
|
|
3
2
|
const require_navigation_hooks = require('./hooks.cjs');
|
|
3
|
+
const require_navigation_Link = require('./Link.cjs');
|
|
4
4
|
const require_navigation_createNavigation = require('./createNavigation.cjs');
|
|
5
5
|
|
|
6
6
|
exports.Link = require_navigation_Link.Link;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
2
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let next_intlayer_server = require("next-intlayer/server");
|
|
4
3
|
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
5
4
|
_intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
|
|
6
5
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
6
|
+
let next_intlayer_server = require("next-intlayer/server");
|
|
7
7
|
let node_module = require("node:module");
|
|
8
8
|
let node_path = require("node:path");
|
|
9
9
|
let _intlayer_config_callers = require("@intlayer/config/callers");
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_server_getLocale = require('./getLocale.cjs');
|
|
3
|
-
const require_getDictionary = require('../getDictionary.cjs');
|
|
4
3
|
const require_getDictionaryDynamic = require('../getDictionaryDynamic.cjs');
|
|
5
|
-
const
|
|
4
|
+
const require_getDictionary = require('../getDictionary.cjs');
|
|
5
|
+
const require_server_getMessages = require('./getMessages.cjs');
|
|
6
6
|
const require_server_getRequestConfig = require('./getRequestConfig.cjs');
|
|
7
|
-
const require_server_setRequestLocale = require('./setRequestLocale.cjs');
|
|
8
|
-
const require_server_setLocale = require('./setLocale.cjs');
|
|
9
7
|
const require_server_getTranslations = require('./getTranslations.cjs');
|
|
10
|
-
const
|
|
8
|
+
const require_server_helpers = require('./helpers.cjs');
|
|
9
|
+
const require_server_setLocale = require('./setLocale.cjs');
|
|
10
|
+
const require_server_setRequestLocale = require('./setRequestLocale.cjs');
|
|
11
11
|
|
|
12
12
|
exports.getDictionary = require_getDictionary.getDictionary;
|
|
13
13
|
exports.getDictionaryDynamic = require_getDictionaryDynamic.getDictionaryDynamic;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_routing = require('../../routing.cjs');
|
|
3
2
|
const require_client_NextIntlClientProvider = require('../../client/NextIntlClientProvider.cjs');
|
|
4
|
-
const
|
|
3
|
+
const require_routing = require('../../routing.cjs');
|
|
5
4
|
const require_server_react_useLocale = require('./useLocale.cjs');
|
|
6
5
|
const require_server_react_helpers = require('./helpers.cjs');
|
|
7
|
-
const require_server_react_useDictionaryDynamic = require('./useDictionaryDynamic.cjs');
|
|
8
6
|
const require_server_react_useDictionary = require('./useDictionary.cjs');
|
|
7
|
+
const require_server_react_useDictionaryDynamic = require('./useDictionaryDynamic.cjs');
|
|
8
|
+
const require_server_react_useTranslations = require('./useTranslations.cjs');
|
|
9
9
|
let _intlayer_use_intl = require("@intlayer/use-intl");
|
|
10
10
|
|
|
11
11
|
Object.defineProperty(exports, 'IntlError', {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { log, routing } from "@intlayer/config/built";
|
|
4
|
-
import { IntlayerProvider } from "next-intlayer";
|
|
5
4
|
import { CYAN } from "@intlayer/config/colors";
|
|
6
5
|
import { colorize, getAppLogger } from "@intlayer/config/logger";
|
|
7
6
|
import { getLocaleFromPath } from "@intlayer/core/localization";
|
|
8
7
|
import { usePathname } from "next/navigation";
|
|
8
|
+
import { IntlayerProvider } from "next-intlayer";
|
|
9
9
|
import { jsx } from "react/jsx-runtime";
|
|
10
10
|
|
|
11
11
|
//#region src/client/NextIntlClientProvider.tsx
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineRouting } from "./routing.mjs";
|
|
2
1
|
import { NextIntlClientProvider } from "./client/NextIntlClientProvider.mjs";
|
|
3
2
|
import { useLocale } from "./client/useLocale.mjs";
|
|
4
3
|
import { IntlProvider, useDictionary, useDictionaryDynamic, useExtracted, useFormatter, useMessages, useNow, useTimeZone, useTranslations } from "./client/index.mjs";
|
|
4
|
+
import { defineRouting } from "./routing.mjs";
|
|
5
5
|
import { IntlError, IntlErrorCode, createFormatter, createTranslator, hasLocale, initializeConfig } from "@intlayer/use-intl";
|
|
6
6
|
|
|
7
7
|
export { IntlError, IntlErrorCode, IntlProvider, NextIntlClientProvider, createFormatter, createTranslator, defineRouting, hasLocale, initializeConfig, useDictionary, useDictionaryDynamic, useExtracted, useFormatter, useLocale, useMessages, useNow, useTimeZone, useTranslations };
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { localizeHref } from "./localizeHref.mjs";
|
|
4
4
|
import { useLocale } from "next-intlayer";
|
|
5
|
-
import { forwardRef } from "react";
|
|
6
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { forwardRef } from "react";
|
|
7
7
|
import NextLink from "next/link";
|
|
8
8
|
|
|
9
9
|
//#region src/navigation/Link.tsx
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { localizeHref } from "./localizeHref.mjs";
|
|
2
|
-
import { Link } from "./Link.mjs";
|
|
3
2
|
import { usePathname as usePathname$1, useRouter as useRouter$1 } from "./hooks.mjs";
|
|
3
|
+
import { Link } from "./Link.mjs";
|
|
4
4
|
import { permanentRedirect, redirect } from "next/navigation";
|
|
5
5
|
|
|
6
6
|
//#region src/navigation/createNavigation.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { localizeHref } from "./localizeHref.mjs";
|
|
4
|
-
import { useLocale } from "next-intlayer";
|
|
5
4
|
import { usePathname as usePathname$1, useRouter as useRouter$1 } from "next/navigation";
|
|
5
|
+
import { useLocale } from "next-intlayer";
|
|
6
6
|
|
|
7
7
|
//#region src/navigation/hooks.ts
|
|
8
8
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Link } from "./Link.mjs";
|
|
2
1
|
import { usePathname, useRouter } from "./hooks.mjs";
|
|
2
|
+
import { Link } from "./Link.mjs";
|
|
3
3
|
import { createNavigation } from "./createNavigation.mjs";
|
|
4
4
|
|
|
5
5
|
export { Link, createNavigation, createNavigation as default, usePathname, useRouter };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { withIntlayer } from "next-intlayer/server";
|
|
2
1
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
3
2
|
import { colorize, getAppLogger } from "@intlayer/config/logger";
|
|
3
|
+
import { withIntlayer } from "next-intlayer/server";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
6
6
|
import { NEXT_INTL_CALLERS } from "@intlayer/config/callers";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getLocale } from "./getLocale.mjs";
|
|
2
|
-
import { getDictionary } from "../getDictionary.mjs";
|
|
3
2
|
import { getDictionaryDynamic } from "../getDictionaryDynamic.mjs";
|
|
4
|
-
import {
|
|
3
|
+
import { getDictionary } from "../getDictionary.mjs";
|
|
4
|
+
import { getMessages } from "./getMessages.mjs";
|
|
5
5
|
import getRequestConfig from "./getRequestConfig.mjs";
|
|
6
|
-
import { setRequestLocale } from "./setRequestLocale.mjs";
|
|
7
|
-
import { setLocale } from "./setLocale.mjs";
|
|
8
6
|
import { getTranslations } from "./getTranslations.mjs";
|
|
9
|
-
import {
|
|
7
|
+
import { getFormatter, getNow, getTimeZone } from "./helpers.mjs";
|
|
8
|
+
import { setLocale } from "./setLocale.mjs";
|
|
9
|
+
import { setRequestLocale } from "./setRequestLocale.mjs";
|
|
10
10
|
|
|
11
11
|
export { getDictionary, getDictionaryDynamic, getFormatter, getLocale, getMessages, getNow, getRequestConfig, getTimeZone, getTranslations, setLocale, setRequestLocale };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { defineRouting } from "../../routing.mjs";
|
|
2
1
|
import { NextIntlClientProvider } from "../../client/NextIntlClientProvider.mjs";
|
|
3
|
-
import {
|
|
2
|
+
import { defineRouting } from "../../routing.mjs";
|
|
4
3
|
import { useLocale } from "./useLocale.mjs";
|
|
5
4
|
import { useFormatter, useNow, useTimeZone } from "./helpers.mjs";
|
|
6
|
-
import { useDictionaryDynamic } from "./useDictionaryDynamic.mjs";
|
|
7
5
|
import { useDictionary } from "./useDictionary.mjs";
|
|
6
|
+
import { useDictionaryDynamic } from "./useDictionaryDynamic.mjs";
|
|
7
|
+
import { useTranslations } from "./useTranslations.mjs";
|
|
8
8
|
import { IntlError, IntlErrorCode, createFormatter, createTranslator, hasLocale, initializeConfig, useMessages } from "@intlayer/use-intl";
|
|
9
9
|
|
|
10
10
|
export { IntlError, IntlErrorCode, NextIntlClientProvider, createFormatter, createTranslator, defineRouting, hasLocale, initializeConfig, useDictionary, useDictionaryDynamic, useFormatter, useLocale, useMessages, useNow, useTimeZone, useTranslations };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/next-intl",
|
|
3
|
-
"version": "9.5.
|
|
3
|
+
"version": "9.5.4-canary.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "next-intl API adapter for intlayer — useTranslations, useLocale, getTranslations, getLocale, NextIntlClientProvider backed by next-intlayer",
|
|
6
6
|
"keywords": [
|
|
@@ -105,20 +105,21 @@
|
|
|
105
105
|
"prepublish": "cp -f ../../README.md ./README.md",
|
|
106
106
|
"publish": "bun publish || true",
|
|
107
107
|
"publish:canary": "bun publish --access public --tag canary || true",
|
|
108
|
+
"publish:ci": "bun ../../scripts/publish-package.mjs",
|
|
108
109
|
"publish:latest": "bun publish --access public --tag latest || true",
|
|
109
110
|
"test": "bun --bun vitest run",
|
|
110
111
|
"test:watch": "bun --bun vitest",
|
|
111
112
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
112
113
|
},
|
|
113
114
|
"dependencies": {
|
|
114
|
-
"@intlayer/config": "9.5.
|
|
115
|
-
"@intlayer/core": "9.5.
|
|
116
|
-
"@intlayer/dictionaries-entry": "9.5.
|
|
117
|
-
"@intlayer/engine": "9.5.
|
|
118
|
-
"@intlayer/types": "9.5.
|
|
119
|
-
"@intlayer/use-intl": "9.5.
|
|
120
|
-
"next-intlayer": "9.5.
|
|
121
|
-
"react-intlayer": "9.5.
|
|
115
|
+
"@intlayer/config": "9.5.4-canary.0",
|
|
116
|
+
"@intlayer/core": "9.5.4-canary.0",
|
|
117
|
+
"@intlayer/dictionaries-entry": "9.5.4-canary.0",
|
|
118
|
+
"@intlayer/engine": "9.5.4-canary.0",
|
|
119
|
+
"@intlayer/types": "9.5.4-canary.0",
|
|
120
|
+
"@intlayer/use-intl": "9.5.4-canary.0",
|
|
121
|
+
"next-intlayer": "9.5.4-canary.0",
|
|
122
|
+
"react-intlayer": "9.5.4-canary.0"
|
|
122
123
|
},
|
|
123
124
|
"devDependencies": {
|
|
124
125
|
"@types/node": "^22",
|
|
@@ -126,11 +127,11 @@
|
|
|
126
127
|
"@utils/ts-config": "1.0.4",
|
|
127
128
|
"@utils/ts-config-types": "1.0.4",
|
|
128
129
|
"@utils/tsdown-config": "1.0.4",
|
|
129
|
-
"next-intl": "4.
|
|
130
|
+
"next-intl": "4.14.5",
|
|
130
131
|
"rimraf": "6.1.3",
|
|
131
132
|
"tsdown": "0.23.0",
|
|
132
133
|
"typescript": "7.0.2",
|
|
133
|
-
"vitest": "5.0.
|
|
134
|
+
"vitest": "5.0.1"
|
|
134
135
|
},
|
|
135
136
|
"peerDependencies": {
|
|
136
137
|
"next": ">=14.0.0",
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_react_server_useLocale = require('./useLocale.cjs');
|
|
3
|
-
let _intlayer_use_intl = require("@intlayer/use-intl");
|
|
4
|
-
|
|
5
|
-
//#region src/react-server/helpers.ts
|
|
6
|
-
/**
|
|
7
|
-
* Server counterparts of use-intl's ambient hooks. They mirror the client
|
|
8
|
-
* versions' signatures so the same component code type-checks on both sides.
|
|
9
|
-
*/
|
|
10
|
-
const useFormatter = (() => (0, _intlayer_use_intl.createFormatter)({ locale: require_react_server_useLocale.useLocale() }));
|
|
11
|
-
/** Current time on the server render. */
|
|
12
|
-
const useNow = (() => /* @__PURE__ */ new Date());
|
|
13
|
-
/** Time zone used by the formatters; UTC unless the app overrides it. */
|
|
14
|
-
const useTimeZone = (() => void 0);
|
|
15
|
-
|
|
16
|
-
//#endregion
|
|
17
|
-
exports.useFormatter = useFormatter;
|
|
18
|
-
exports.useNow = useNow;
|
|
19
|
-
exports.useTimeZone = useTimeZone;
|
|
20
|
-
//# sourceMappingURL=helpers.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.cjs","names":["createFormatter","useLocale"],"sources":["../../../src/react-server/helpers.ts"],"sourcesContent":["import { createFormatter } from '@intlayer/use-intl';\nimport { useLocale } from './useLocale';\n\n/**\n * Server counterparts of use-intl's ambient hooks. They mirror the client\n * versions' signatures so the same component code type-checks on both sides.\n */\nexport const useFormatter: typeof import('@intlayer/use-intl').useFormatter =\n (() => createFormatter({ locale: useLocale() as string })) as never;\n\n/** Current time on the server render. */\nexport const useNow: typeof import('@intlayer/use-intl').useNow = (() =>\n new Date()) as never;\n\n/** Time zone used by the formatters; UTC unless the app overrides it. */\nexport const useTimeZone: typeof import('@intlayer/use-intl').useTimeZone =\n (() => undefined) as never;\n"],"mappings":";;;;;;;;;AAOA,MAAa,0BACJA,oCAAgB,EAAE,QAAQC,yCAAU,EAAY,CAAC;;AAG1D,MAAa,gCACX,IAAI,KAAK;;AAGX,MAAa,qBACJ"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_routing = require('../routing.cjs');
|
|
3
|
-
const require_client_NextIntlClientProvider = require('../client/NextIntlClientProvider.cjs');
|
|
4
|
-
const require_react_server_useTranslations = require('./useTranslations.cjs');
|
|
5
|
-
const require_react_server_useLocale = require('./useLocale.cjs');
|
|
6
|
-
const require_react_server_helpers = require('./helpers.cjs');
|
|
7
|
-
const require_react_server_useDictionaryDynamic = require('./useDictionaryDynamic.cjs');
|
|
8
|
-
const require_react_server_useDictionary = require('./useDictionary.cjs');
|
|
9
|
-
let _intlayer_use_intl = require("@intlayer/use-intl");
|
|
10
|
-
|
|
11
|
-
Object.defineProperty(exports, 'IntlError', {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function () {
|
|
14
|
-
return _intlayer_use_intl.IntlError;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, 'IntlErrorCode', {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () {
|
|
20
|
-
return _intlayer_use_intl.IntlErrorCode;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
exports.NextIntlClientProvider = require_client_NextIntlClientProvider.NextIntlClientProvider;
|
|
24
|
-
Object.defineProperty(exports, 'createFormatter', {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _intlayer_use_intl.createFormatter;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, 'createTranslator', {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _intlayer_use_intl.createTranslator;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
exports.defineRouting = require_routing.defineRouting;
|
|
37
|
-
Object.defineProperty(exports, 'hasLocale', {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
get: function () {
|
|
40
|
-
return _intlayer_use_intl.hasLocale;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
Object.defineProperty(exports, 'initializeConfig', {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _intlayer_use_intl.initializeConfig;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
exports.useDictionary = require_react_server_useDictionary.useDictionary;
|
|
50
|
-
exports.useDictionaryDynamic = require_react_server_useDictionaryDynamic.useDictionaryDynamic;
|
|
51
|
-
exports.useFormatter = require_react_server_helpers.useFormatter;
|
|
52
|
-
exports.useLocale = require_react_server_useLocale.useLocale;
|
|
53
|
-
Object.defineProperty(exports, 'useMessages', {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
get: function () {
|
|
56
|
-
return _intlayer_use_intl.useMessages;
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
exports.useNow = require_react_server_helpers.useNow;
|
|
60
|
-
exports.useTimeZone = require_react_server_helpers.useTimeZone;
|
|
61
|
-
exports.useTranslations = require_react_server_useTranslations.useTranslations;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_server_requestLocaleCache = require('../server/requestLocaleCache.cjs');
|
|
3
|
-
let next_intlayer_server = require("next-intlayer/server");
|
|
4
|
-
|
|
5
|
-
//#region src/react-server/resolveLocale.ts
|
|
6
|
-
/**
|
|
7
|
-
* Locale for a synchronous server hook, resolved the same way `getLocale()`
|
|
8
|
-
* resolves it — so server-rendered content and the client provider never
|
|
9
|
-
* disagree about which locale the request is in.
|
|
10
|
-
*
|
|
11
|
-
* 1. The locale forwarded through `setRequestLocale(locale)` (the `[locale]`
|
|
12
|
-
* route segment), which is next-intl's source of truth for URL routing.
|
|
13
|
-
* 2. Otherwise Intlayer's ambient locale (server context, then the request).
|
|
14
|
-
*/
|
|
15
|
-
const resolveServerLocale = () => require_server_requestLocaleCache.getCachedRequestLocale() ?? (0, next_intlayer_server.useLocale)().locale;
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
exports.resolveServerLocale = resolveServerLocale;
|
|
19
|
-
//# sourceMappingURL=resolveLocale.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveLocale.cjs","names":["getCachedRequestLocale","useLocaleIntlayer"],"sources":["../../../src/react-server/resolveLocale.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useLocale as useLocaleIntlayer } from 'next-intlayer/server';\nimport { getCachedRequestLocale } from '../server/requestLocaleCache';\n\n/**\n * Locale for a synchronous server hook, resolved the same way `getLocale()`\n * resolves it — so server-rendered content and the client provider never\n * disagree about which locale the request is in.\n *\n * 1. The locale forwarded through `setRequestLocale(locale)` (the `[locale]`\n * route segment), which is next-intl's source of truth for URL routing.\n * 2. Otherwise Intlayer's ambient locale (server context, then the request).\n */\nexport const resolveServerLocale = (): LocalesValues =>\n (getCachedRequestLocale() ??\n useLocaleIntlayer().locale) as LocalesValues;\n"],"mappings":";;;;;;;;;;;;;;AAaA,MAAa,4BACVA,yDAAuB,SACtBC,gCAAkB,CAAC,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_react_server_resolveLocale = require('./resolveLocale.cjs');
|
|
3
|
-
let _intlayer_use_intl = require("@intlayer/use-intl");
|
|
4
|
-
let next_intlayer_server = require("next-intlayer/server");
|
|
5
|
-
|
|
6
|
-
//#region src/react-server/useDictionary.ts
|
|
7
|
-
/**
|
|
8
|
-
* Server counterpart of `@intlayer/use-intl`'s `useDictionary`.
|
|
9
|
-
*
|
|
10
|
-
* The optimize pass rewrites every `useTranslations(...)` call to this helper
|
|
11
|
-
* with the dictionary pre-imported. Resolving it here — rather than in a client
|
|
12
|
-
* component — keeps the dictionary out of the client bundle entirely: the
|
|
13
|
-
* server renders the text and only the rendered output crosses the boundary.
|
|
14
|
-
*/
|
|
15
|
-
const useDictionary = ((dictionary, namespacePrefix) => {
|
|
16
|
-
const locale = require_react_server_resolveLocale.resolveServerLocale();
|
|
17
|
-
const content = (0, next_intlayer_server.useDictionary)(dictionary, locale);
|
|
18
|
-
return (0, _intlayer_use_intl.createDictionaryTranslator)(locale, content, namespacePrefix);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
//#endregion
|
|
22
|
-
exports.useDictionary = useDictionary;
|
|
23
|
-
//# sourceMappingURL=useDictionary.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.cjs","names":["resolveServerLocale","useDictionaryBase","createDictionaryTranslator"],"sources":["../../../src/react-server/useDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n createDictionaryTranslator,\n type ScopedTranslateFunction,\n type TranslateFunction,\n} from '@intlayer/use-intl';\nimport { useDictionary as useDictionaryBase } from 'next-intlayer/server';\nimport { resolveServerLocale } from './resolveLocale';\n\n/**\n * Overload set mirroring the client `useDictionary` exactly, so the optimize\n * pass can emit the same call shape whichever side of the boundary the\n * component ends up on.\n */\ntype UseDictionary = {\n <T extends Dictionary>(\n dictionary: T\n ): TranslateFunction<T['key'] & DictionaryKeys>;\n <T extends Dictionary, Prefix extends string>(\n dictionary: T,\n namespacePrefix: Prefix\n ): ScopedTranslateFunction<T['key'] & DictionaryKeys, Prefix>;\n};\n\n/**\n * Server counterpart of `@intlayer/use-intl`'s `useDictionary`.\n *\n * The optimize pass rewrites every `useTranslations(...)` call to this helper\n * with the dictionary pre-imported. Resolving it here — rather than in a client\n * component — keeps the dictionary out of the client bundle entirely: the\n * server renders the text and only the rendered output crosses the boundary.\n */\nexport const useDictionary = (<T extends Dictionary>(\n dictionary: T,\n namespacePrefix?: string\n) => {\n const locale = resolveServerLocale();\n const content = useDictionaryBase(dictionary, locale as never);\n\n return createDictionaryTranslator(\n locale,\n content,\n namespacePrefix\n );\n}) as UseDictionary;\n"],"mappings":";;;;;;;;;;;;;;AAoCA,MAAa,kBACX,YACA,oBACG;CACH,MAAM,SAASA,uDAAoB;CACnC,MAAM,cAAUC,oCAAkB,YAAY,MAAe;CAE7D,WAAOC,+CACL,QACA,SACA,eACF;AACF"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_react_server_resolveLocale = require('./resolveLocale.cjs');
|
|
3
|
-
let _intlayer_use_intl = require("@intlayer/use-intl");
|
|
4
|
-
let next_intlayer_server = require("next-intlayer/server");
|
|
5
|
-
|
|
6
|
-
//#region src/react-server/useDictionaryDynamic.ts
|
|
7
|
-
/**
|
|
8
|
-
* Server counterpart of `useDictionaryDynamic`, emitted by the optimize pass
|
|
9
|
-
* for dictionaries on the per-locale loader.
|
|
10
|
-
*/
|
|
11
|
-
const useDictionaryDynamic = ((dictionaryPromise, key, namespacePrefix) => {
|
|
12
|
-
const locale = require_react_server_resolveLocale.resolveServerLocale();
|
|
13
|
-
const content = (0, next_intlayer_server.useDictionaryDynamic)(dictionaryPromise, key, locale);
|
|
14
|
-
return (0, _intlayer_use_intl.createDictionaryTranslator)(locale, content, namespacePrefix);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
//#endregion
|
|
18
|
-
exports.useDictionaryDynamic = useDictionaryDynamic;
|
|
19
|
-
//# sourceMappingURL=useDictionaryDynamic.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.cjs","names":["resolveServerLocale","useDictionaryDynamicBase","createDictionaryTranslator"],"sources":["../../../src/react-server/useDictionaryDynamic.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n createDictionaryTranslator,\n type ScopedTranslateFunction,\n type TranslateFunction,\n} from '@intlayer/use-intl';\nimport { useDictionaryDynamic as useDictionaryDynamicBase } from 'next-intlayer/server';\nimport { resolveServerLocale } from './resolveLocale';\n\ntype UseDictionaryDynamic = {\n <T extends Dictionary, K extends DictionaryKeys>(\n dictionaryPromise: Record<string, () => Promise<T>>,\n key: K\n ): TranslateFunction<K>;\n <T extends Dictionary, K extends DictionaryKeys, Prefix extends string>(\n dictionaryPromise: Record<string, () => Promise<T>>,\n key: K,\n namespacePrefix: Prefix\n ): ScopedTranslateFunction<K, Prefix>;\n};\n\n/**\n * Server counterpart of `useDictionaryDynamic`, emitted by the optimize pass\n * for dictionaries on the per-locale loader.\n */\nexport const useDictionaryDynamic = ((\n dictionaryPromise: Record<string, () => Promise<Dictionary>>,\n key: string,\n namespacePrefix?: string\n) => {\n const locale = resolveServerLocale();\n const content = useDictionaryDynamicBase(\n dictionaryPromise as never,\n key as never,\n locale as never\n );\n\n return createDictionaryTranslator(\n locale,\n content,\n namespacePrefix\n );\n}) as UseDictionaryDynamic;\n"],"mappings":";;;;;;;;;;AA6BA,MAAa,yBACX,mBACA,KACA,oBACG;CACH,MAAM,SAASA,uDAAoB;CACnC,MAAM,cAAUC,2CACd,mBACA,KACA,MACF;CAEA,WAAOC,+CACL,QACA,SACA,eACF;AACF"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_react_server_resolveLocale = require('./resolveLocale.cjs');
|
|
3
|
-
|
|
4
|
-
//#region src/react-server/useLocale.ts
|
|
5
|
-
/**
|
|
6
|
-
* Server counterpart of `useLocale`, resolved from the `[locale]` route segment
|
|
7
|
-
* forwarded through `setRequestLocale` when the app provides one.
|
|
8
|
-
*/
|
|
9
|
-
const useLocale = () => require_react_server_resolveLocale.resolveServerLocale();
|
|
10
|
-
|
|
11
|
-
//#endregion
|
|
12
|
-
exports.useLocale = useLocale;
|
|
13
|
-
//# sourceMappingURL=useLocale.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.cjs","names":["resolveServerLocale"],"sources":["../../../src/react-server/useLocale.ts"],"sourcesContent":["import type { useLocale as _useLocale } from 'next-intl';\nimport { resolveServerLocale } from './resolveLocale';\n\n/**\n * Server counterpart of `useLocale`, resolved from the `[locale]` route segment\n * forwarded through `setRequestLocale` when the app provides one.\n */\nexport const useLocale: typeof _useLocale = () =>\n resolveServerLocale() as ReturnType<typeof _useLocale>;\n"],"mappings":";;;;;;;;AAOA,MAAa,kBACXA,uDAAoB"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_react_server_resolveLocale = require('./resolveLocale.cjs');
|
|
3
|
-
let _intlayer_use_intl = require("@intlayer/use-intl");
|
|
4
|
-
let next_intlayer_server = require("next-intlayer/server");
|
|
5
|
-
|
|
6
|
-
//#region src/react-server/useTranslations.ts
|
|
7
|
-
/** Splits `'about.counter'` into the dictionary key and its key prefix. */
|
|
8
|
-
const splitNamespace = (namespace) => {
|
|
9
|
-
const dotPosition = namespace.indexOf(".");
|
|
10
|
-
if (dotPosition === -1) return [namespace, void 0];
|
|
11
|
-
return [namespace.slice(0, dotPosition), namespace.slice(dotPosition + 1)];
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Server counterpart of `useTranslations`.
|
|
15
|
-
*
|
|
16
|
-
* next-intl's `useTranslations` is isomorphic — the same component code runs in
|
|
17
|
-
* a Server or a Client Component — so the adapter has to be too. Without this
|
|
18
|
-
* every component calling it is forced across the client boundary, which drags
|
|
19
|
-
* its dictionary into a client chunk that Next shares across every locale.
|
|
20
|
-
*
|
|
21
|
-
* The optimize pass normally rewrites these calls to `useDictionary` with the
|
|
22
|
-
* dictionary inlined; this runtime path covers the calls it could not resolve
|
|
23
|
-
* statically (a dynamic namespace, or an unoptimized build).
|
|
24
|
-
*/
|
|
25
|
-
const useTranslations = ((namespace) => {
|
|
26
|
-
const locale = require_react_server_resolveLocale.resolveServerLocale();
|
|
27
|
-
if (!namespace) {
|
|
28
|
-
const rootTranslator = (key, values) => {
|
|
29
|
-
const [dictionaryKey, keyPrefix] = splitNamespace(key);
|
|
30
|
-
const content = (0, next_intlayer_server.useIntlayer)(dictionaryKey, locale);
|
|
31
|
-
return (0, _intlayer_use_intl.createDictionaryTranslator)(locale, content, void 0)(keyPrefix ?? "", values);
|
|
32
|
-
};
|
|
33
|
-
return rootTranslator;
|
|
34
|
-
}
|
|
35
|
-
const [dictionaryKey, keyPrefix] = splitNamespace(namespace);
|
|
36
|
-
const content = (0, next_intlayer_server.useIntlayer)(dictionaryKey, locale);
|
|
37
|
-
return (0, _intlayer_use_intl.createDictionaryTranslator)(locale, content, keyPrefix);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
//#endregion
|
|
41
|
-
exports.useTranslations = useTranslations;
|
|
42
|
-
//# sourceMappingURL=useTranslations.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useTranslations.cjs","names":["resolveServerLocale","useIntlayer","createDictionaryTranslator"],"sources":["../../../src/react-server/useTranslations.ts"],"sourcesContent":["import type { DictionaryKeys } from '@intlayer/types/module_augmentation';\nimport {\n createDictionaryTranslator,\n type LooseTranslateFunction,\n type TranslateFunction,\n type TranslateFunctionForNamespace,\n} from '@intlayer/use-intl';\nimport { useIntlayer } from 'next-intlayer/server';\nimport { resolveServerLocale } from './resolveLocale';\n\ntype UseTranslations = {\n <N extends DictionaryKeys>(namespace: N): TranslateFunction<N>;\n <N extends `${string}.${string}`>(\n namespace: N\n ): TranslateFunctionForNamespace<N>;\n (): LooseTranslateFunction;\n};\n\n/** Splits `'about.counter'` into the dictionary key and its key prefix. */\nconst splitNamespace = (namespace: string): [string, string | undefined] => {\n const dotPosition = namespace.indexOf('.');\n if (dotPosition === -1) return [namespace, undefined];\n return [namespace.slice(0, dotPosition), namespace.slice(dotPosition + 1)];\n};\n\n/**\n * Server counterpart of `useTranslations`.\n *\n * next-intl's `useTranslations` is isomorphic — the same component code runs in\n * a Server or a Client Component — so the adapter has to be too. Without this\n * every component calling it is forced across the client boundary, which drags\n * its dictionary into a client chunk that Next shares across every locale.\n *\n * The optimize pass normally rewrites these calls to `useDictionary` with the\n * dictionary inlined; this runtime path covers the calls it could not resolve\n * statically (a dynamic namespace, or an unoptimized build).\n */\nexport const useTranslations = ((namespace?: string) => {\n const locale = resolveServerLocale();\n\n if (!namespace) {\n // Root scope: the first segment of each message id names the dictionary,\n // so the lookup can only happen per call.\n const rootTranslator = (key: string, values?: Record<string, unknown>) => {\n const [dictionaryKey, keyPrefix] = splitNamespace(key);\n const content = useIntlayer(dictionaryKey as never, locale as never);\n const translate = createDictionaryTranslator(locale, content, undefined);\n return translate(keyPrefix ?? '', values as never);\n };\n return rootTranslator as unknown as LooseTranslateFunction;\n }\n\n const [dictionaryKey, keyPrefix] = splitNamespace(namespace);\n const content = useIntlayer(dictionaryKey as never, locale as never);\n\n return createDictionaryTranslator(locale, content, keyPrefix);\n}) as UseTranslations;\n"],"mappings":";;;;;;;AAmBA,MAAM,kBAAkB,cAAoD;CAC1E,MAAM,cAAc,UAAU,QAAQ,GAAG;CACzC,IAAI,gBAAgB,IAAI,OAAO,CAAC,WAAW,MAAS;CACpD,OAAO,CAAC,UAAU,MAAM,GAAG,WAAW,GAAG,UAAU,MAAM,cAAc,CAAC,CAAC;AAC3E;;;;;;;;;;;;;AAcA,MAAa,oBAAoB,cAAuB;CACtD,MAAM,SAASA,uDAAoB;CAEnC,IAAI,CAAC,WAAW;EAGd,MAAM,kBAAkB,KAAa,WAAqC;GACxE,MAAM,CAAC,eAAe,aAAa,eAAe,GAAG;GACrD,MAAM,cAAUC,kCAAY,eAAwB,MAAe;GAEnE,WADkBC,+CAA2B,QAAQ,SAAS,MAC/C,CAAC,CAAC,aAAa,IAAI,MAAe;EACnD;EACA,OAAO;CACT;CAEA,MAAM,CAAC,eAAe,aAAa,eAAe,SAAS;CAC3D,MAAM,cAAUD,kCAAY,eAAwB,MAAe;CAEnE,WAAOC,+CAA2B,QAAQ,SAAS,SAAS;AAC9D"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
let _intlayer_config_built = require("@intlayer/config/built");
|
|
3
|
-
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
4
|
-
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
5
|
-
|
|
6
|
-
//#region src/warnUnsupported.ts
|
|
7
|
-
/**
|
|
8
|
-
* Warns, in development only, that a `next-intl` API is a no-op under the
|
|
9
|
-
* intlayer adapter.
|
|
10
|
-
*
|
|
11
|
-
* The `NODE_ENV` check is what keeps `@intlayer/config`'s logger and its ANSI
|
|
12
|
-
* colour table — around 6 KB — out of production bundles: with the branch
|
|
13
|
-
* folded away nothing references the imports any more and they are shaken out.
|
|
14
|
-
* That only works while `process.env.NODE_ENV` survives this package's own
|
|
15
|
-
* build and reaches the consuming app's bundler, which is why `tsdown.config.ts`
|
|
16
|
-
* pins `platform: 'neutral'`.
|
|
17
|
-
*
|
|
18
|
-
* @param api - Name of the shimmed `next-intl` export, e.g. `getMessages`.
|
|
19
|
-
* @param reason - What the developer should do instead.
|
|
20
|
-
*/
|
|
21
|
-
const warnUnsupported = (api, reason) => {
|
|
22
|
-
if (process.env.NODE_ENV !== "development") return;
|
|
23
|
-
(0, _intlayer_config_logger.getAppLogger)({ log: _intlayer_config_built.log })(`${(0, _intlayer_config_logger.colorize)(api, _intlayer_config_colors.CYAN)} ${reason}`);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
exports.warnUnsupported = warnUnsupported;
|
|
28
|
-
//# sourceMappingURL=warnUnsupported.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"warnUnsupported.cjs","names":["colorize","CYAN"],"sources":["../../src/warnUnsupported.ts"],"sourcesContent":["import { log } from '@intlayer/config/built';\nimport { CYAN } from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\n\n/**\n * Warns, in development only, that a `next-intl` API is a no-op under the\n * intlayer adapter.\n *\n * The `NODE_ENV` check is what keeps `@intlayer/config`'s logger and its ANSI\n * colour table — around 6 KB — out of production bundles: with the branch\n * folded away nothing references the imports any more and they are shaken out.\n * That only works while `process.env.NODE_ENV` survives this package's own\n * build and reaches the consuming app's bundler, which is why `tsdown.config.ts`\n * pins `platform: 'neutral'`.\n *\n * @param api - Name of the shimmed `next-intl` export, e.g. `getMessages`.\n * @param reason - What the developer should do instead.\n */\nexport const warnUnsupported = (api: string, reason: string): void => {\n if (process.env.NODE_ENV !== 'development') return;\n\n getAppLogger({ log })(`${colorize(api, CYAN)} ${reason}`);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkBA,MAAa,mBAAmB,KAAa,WAAyB;CACpE,IAAI,QAAQ,IAAI,aAAa,eAAe;CAE5C,0CAAa,EAAE,gCAAI,CAAC,CAAC,CAAC,OAAGA,kCAAS,KAAKC,4BAAI,EAAE,GAAG,QAAQ;AAC1D"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { useLocale } from "./useLocale.mjs";
|
|
2
|
-
import { createFormatter } from "@intlayer/use-intl";
|
|
3
|
-
|
|
4
|
-
//#region src/react-server/helpers.ts
|
|
5
|
-
/**
|
|
6
|
-
* Server counterparts of use-intl's ambient hooks. They mirror the client
|
|
7
|
-
* versions' signatures so the same component code type-checks on both sides.
|
|
8
|
-
*/
|
|
9
|
-
const useFormatter = (() => createFormatter({ locale: useLocale() }));
|
|
10
|
-
/** Current time on the server render. */
|
|
11
|
-
const useNow = (() => /* @__PURE__ */ new Date());
|
|
12
|
-
/** Time zone used by the formatters; UTC unless the app overrides it. */
|
|
13
|
-
const useTimeZone = (() => void 0);
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
export { useFormatter, useNow, useTimeZone };
|
|
17
|
-
//# sourceMappingURL=helpers.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.mjs","names":[],"sources":["../../../src/react-server/helpers.ts"],"sourcesContent":["import { createFormatter } from '@intlayer/use-intl';\nimport { useLocale } from './useLocale';\n\n/**\n * Server counterparts of use-intl's ambient hooks. They mirror the client\n * versions' signatures so the same component code type-checks on both sides.\n */\nexport const useFormatter: typeof import('@intlayer/use-intl').useFormatter =\n (() => createFormatter({ locale: useLocale() as string })) as never;\n\n/** Current time on the server render. */\nexport const useNow: typeof import('@intlayer/use-intl').useNow = (() =>\n new Date()) as never;\n\n/** Time zone used by the formatters; UTC unless the app overrides it. */\nexport const useTimeZone: typeof import('@intlayer/use-intl').useTimeZone =\n (() => undefined) as never;\n"],"mappings":";;;;;;;;AAOA,MAAa,sBACJ,gBAAgB,EAAE,QAAQ,UAAU,EAAY,CAAC;;AAG1D,MAAa,gCACX,IAAI,KAAK;;AAGX,MAAa,qBACJ"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { defineRouting } from "../routing.mjs";
|
|
2
|
-
import { NextIntlClientProvider } from "../client/NextIntlClientProvider.mjs";
|
|
3
|
-
import { useTranslations } from "./useTranslations.mjs";
|
|
4
|
-
import { useLocale } from "./useLocale.mjs";
|
|
5
|
-
import { useFormatter, useNow, useTimeZone } from "./helpers.mjs";
|
|
6
|
-
import { useDictionaryDynamic } from "./useDictionaryDynamic.mjs";
|
|
7
|
-
import { useDictionary } from "./useDictionary.mjs";
|
|
8
|
-
import { IntlError, IntlErrorCode, createFormatter, createTranslator, hasLocale, initializeConfig, useMessages } from "@intlayer/use-intl";
|
|
9
|
-
|
|
10
|
-
export { IntlError, IntlErrorCode, NextIntlClientProvider, createFormatter, createTranslator, defineRouting, hasLocale, initializeConfig, useDictionary, useDictionaryDynamic, useFormatter, useLocale, useMessages, useNow, useTimeZone, useTranslations };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { getCachedRequestLocale } from "../server/requestLocaleCache.mjs";
|
|
2
|
-
import { useLocale } from "next-intlayer/server";
|
|
3
|
-
|
|
4
|
-
//#region src/react-server/resolveLocale.ts
|
|
5
|
-
/**
|
|
6
|
-
* Locale for a synchronous server hook, resolved the same way `getLocale()`
|
|
7
|
-
* resolves it — so server-rendered content and the client provider never
|
|
8
|
-
* disagree about which locale the request is in.
|
|
9
|
-
*
|
|
10
|
-
* 1. The locale forwarded through `setRequestLocale(locale)` (the `[locale]`
|
|
11
|
-
* route segment), which is next-intl's source of truth for URL routing.
|
|
12
|
-
* 2. Otherwise Intlayer's ambient locale (server context, then the request).
|
|
13
|
-
*/
|
|
14
|
-
const resolveServerLocale = () => getCachedRequestLocale() ?? useLocale().locale;
|
|
15
|
-
|
|
16
|
-
//#endregion
|
|
17
|
-
export { resolveServerLocale };
|
|
18
|
-
//# sourceMappingURL=resolveLocale.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveLocale.mjs","names":["useLocaleIntlayer"],"sources":["../../../src/react-server/resolveLocale.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useLocale as useLocaleIntlayer } from 'next-intlayer/server';\nimport { getCachedRequestLocale } from '../server/requestLocaleCache';\n\n/**\n * Locale for a synchronous server hook, resolved the same way `getLocale()`\n * resolves it — so server-rendered content and the client provider never\n * disagree about which locale the request is in.\n *\n * 1. The locale forwarded through `setRequestLocale(locale)` (the `[locale]`\n * route segment), which is next-intl's source of truth for URL routing.\n * 2. Otherwise Intlayer's ambient locale (server context, then the request).\n */\nexport const resolveServerLocale = (): LocalesValues =>\n (getCachedRequestLocale() ??\n useLocaleIntlayer().locale) as LocalesValues;\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAa,4BACV,uBAAuB,KACtBA,UAAkB,CAAC,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { resolveServerLocale } from "./resolveLocale.mjs";
|
|
2
|
-
import { createDictionaryTranslator } from "@intlayer/use-intl";
|
|
3
|
-
import { useDictionary as useDictionary$1 } from "next-intlayer/server";
|
|
4
|
-
|
|
5
|
-
//#region src/react-server/useDictionary.ts
|
|
6
|
-
/**
|
|
7
|
-
* Server counterpart of `@intlayer/use-intl`'s `useDictionary`.
|
|
8
|
-
*
|
|
9
|
-
* The optimize pass rewrites every `useTranslations(...)` call to this helper
|
|
10
|
-
* with the dictionary pre-imported. Resolving it here — rather than in a client
|
|
11
|
-
* component — keeps the dictionary out of the client bundle entirely: the
|
|
12
|
-
* server renders the text and only the rendered output crosses the boundary.
|
|
13
|
-
*/
|
|
14
|
-
const useDictionary = ((dictionary, namespacePrefix) => {
|
|
15
|
-
const locale = resolveServerLocale();
|
|
16
|
-
const content = useDictionary$1(dictionary, locale);
|
|
17
|
-
return createDictionaryTranslator(locale, content, namespacePrefix);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
export { useDictionary };
|
|
22
|
-
//# sourceMappingURL=useDictionary.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.mjs","names":["useDictionaryBase"],"sources":["../../../src/react-server/useDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n createDictionaryTranslator,\n type ScopedTranslateFunction,\n type TranslateFunction,\n} from '@intlayer/use-intl';\nimport { useDictionary as useDictionaryBase } from 'next-intlayer/server';\nimport { resolveServerLocale } from './resolveLocale';\n\n/**\n * Overload set mirroring the client `useDictionary` exactly, so the optimize\n * pass can emit the same call shape whichever side of the boundary the\n * component ends up on.\n */\ntype UseDictionary = {\n <T extends Dictionary>(\n dictionary: T\n ): TranslateFunction<T['key'] & DictionaryKeys>;\n <T extends Dictionary, Prefix extends string>(\n dictionary: T,\n namespacePrefix: Prefix\n ): ScopedTranslateFunction<T['key'] & DictionaryKeys, Prefix>;\n};\n\n/**\n * Server counterpart of `@intlayer/use-intl`'s `useDictionary`.\n *\n * The optimize pass rewrites every `useTranslations(...)` call to this helper\n * with the dictionary pre-imported. Resolving it here — rather than in a client\n * component — keeps the dictionary out of the client bundle entirely: the\n * server renders the text and only the rendered output crosses the boundary.\n */\nexport const useDictionary = (<T extends Dictionary>(\n dictionary: T,\n namespacePrefix?: string\n) => {\n const locale = resolveServerLocale();\n const content = useDictionaryBase(dictionary, locale as never);\n\n return createDictionaryTranslator(\n locale,\n content,\n namespacePrefix\n );\n}) as UseDictionary;\n"],"mappings":";;;;;;;;;;;;;AAoCA,MAAa,kBACX,YACA,oBACG;CACH,MAAM,SAAS,oBAAoB;CACnC,MAAM,UAAUA,gBAAkB,YAAY,MAAe;CAE7D,OAAO,2BACL,QACA,SACA,eACF;AACF"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { resolveServerLocale } from "./resolveLocale.mjs";
|
|
2
|
-
import { createDictionaryTranslator } from "@intlayer/use-intl";
|
|
3
|
-
import { useDictionaryDynamic as useDictionaryDynamic$1 } from "next-intlayer/server";
|
|
4
|
-
|
|
5
|
-
//#region src/react-server/useDictionaryDynamic.ts
|
|
6
|
-
/**
|
|
7
|
-
* Server counterpart of `useDictionaryDynamic`, emitted by the optimize pass
|
|
8
|
-
* for dictionaries on the per-locale loader.
|
|
9
|
-
*/
|
|
10
|
-
const useDictionaryDynamic = ((dictionaryPromise, key, namespacePrefix) => {
|
|
11
|
-
const locale = resolveServerLocale();
|
|
12
|
-
const content = useDictionaryDynamic$1(dictionaryPromise, key, locale);
|
|
13
|
-
return createDictionaryTranslator(locale, content, namespacePrefix);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
//#endregion
|
|
17
|
-
export { useDictionaryDynamic };
|
|
18
|
-
//# sourceMappingURL=useDictionaryDynamic.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.mjs","names":["useDictionaryDynamicBase"],"sources":["../../../src/react-server/useDictionaryDynamic.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n createDictionaryTranslator,\n type ScopedTranslateFunction,\n type TranslateFunction,\n} from '@intlayer/use-intl';\nimport { useDictionaryDynamic as useDictionaryDynamicBase } from 'next-intlayer/server';\nimport { resolveServerLocale } from './resolveLocale';\n\ntype UseDictionaryDynamic = {\n <T extends Dictionary, K extends DictionaryKeys>(\n dictionaryPromise: Record<string, () => Promise<T>>,\n key: K\n ): TranslateFunction<K>;\n <T extends Dictionary, K extends DictionaryKeys, Prefix extends string>(\n dictionaryPromise: Record<string, () => Promise<T>>,\n key: K,\n namespacePrefix: Prefix\n ): ScopedTranslateFunction<K, Prefix>;\n};\n\n/**\n * Server counterpart of `useDictionaryDynamic`, emitted by the optimize pass\n * for dictionaries on the per-locale loader.\n */\nexport const useDictionaryDynamic = ((\n dictionaryPromise: Record<string, () => Promise<Dictionary>>,\n key: string,\n namespacePrefix?: string\n) => {\n const locale = resolveServerLocale();\n const content = useDictionaryDynamicBase(\n dictionaryPromise as never,\n key as never,\n locale as never\n );\n\n return createDictionaryTranslator(\n locale,\n content,\n namespacePrefix\n );\n}) as UseDictionaryDynamic;\n"],"mappings":";;;;;;;;;AA6BA,MAAa,yBACX,mBACA,KACA,oBACG;CACH,MAAM,SAAS,oBAAoB;CACnC,MAAM,UAAUA,uBACd,mBACA,KACA,MACF;CAEA,OAAO,2BACL,QACA,SACA,eACF;AACF"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { resolveServerLocale } from "./resolveLocale.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/react-server/useLocale.ts
|
|
4
|
-
/**
|
|
5
|
-
* Server counterpart of `useLocale`, resolved from the `[locale]` route segment
|
|
6
|
-
* forwarded through `setRequestLocale` when the app provides one.
|
|
7
|
-
*/
|
|
8
|
-
const useLocale = () => resolveServerLocale();
|
|
9
|
-
|
|
10
|
-
//#endregion
|
|
11
|
-
export { useLocale };
|
|
12
|
-
//# sourceMappingURL=useLocale.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.mjs","names":[],"sources":["../../../src/react-server/useLocale.ts"],"sourcesContent":["import type { useLocale as _useLocale } from 'next-intl';\nimport { resolveServerLocale } from './resolveLocale';\n\n/**\n * Server counterpart of `useLocale`, resolved from the `[locale]` route segment\n * forwarded through `setRequestLocale` when the app provides one.\n */\nexport const useLocale: typeof _useLocale = () =>\n resolveServerLocale() as ReturnType<typeof _useLocale>;\n"],"mappings":";;;;;;;AAOA,MAAa,kBACX,oBAAoB"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { resolveServerLocale } from "./resolveLocale.mjs";
|
|
2
|
-
import { createDictionaryTranslator } from "@intlayer/use-intl";
|
|
3
|
-
import { useIntlayer } from "next-intlayer/server";
|
|
4
|
-
|
|
5
|
-
//#region src/react-server/useTranslations.ts
|
|
6
|
-
/** Splits `'about.counter'` into the dictionary key and its key prefix. */
|
|
7
|
-
const splitNamespace = (namespace) => {
|
|
8
|
-
const dotPosition = namespace.indexOf(".");
|
|
9
|
-
if (dotPosition === -1) return [namespace, void 0];
|
|
10
|
-
return [namespace.slice(0, dotPosition), namespace.slice(dotPosition + 1)];
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Server counterpart of `useTranslations`.
|
|
14
|
-
*
|
|
15
|
-
* next-intl's `useTranslations` is isomorphic — the same component code runs in
|
|
16
|
-
* a Server or a Client Component — so the adapter has to be too. Without this
|
|
17
|
-
* every component calling it is forced across the client boundary, which drags
|
|
18
|
-
* its dictionary into a client chunk that Next shares across every locale.
|
|
19
|
-
*
|
|
20
|
-
* The optimize pass normally rewrites these calls to `useDictionary` with the
|
|
21
|
-
* dictionary inlined; this runtime path covers the calls it could not resolve
|
|
22
|
-
* statically (a dynamic namespace, or an unoptimized build).
|
|
23
|
-
*/
|
|
24
|
-
const useTranslations = ((namespace) => {
|
|
25
|
-
const locale = resolveServerLocale();
|
|
26
|
-
if (!namespace) {
|
|
27
|
-
const rootTranslator = (key, values) => {
|
|
28
|
-
const [dictionaryKey, keyPrefix] = splitNamespace(key);
|
|
29
|
-
const content = useIntlayer(dictionaryKey, locale);
|
|
30
|
-
return createDictionaryTranslator(locale, content, void 0)(keyPrefix ?? "", values);
|
|
31
|
-
};
|
|
32
|
-
return rootTranslator;
|
|
33
|
-
}
|
|
34
|
-
const [dictionaryKey, keyPrefix] = splitNamespace(namespace);
|
|
35
|
-
const content = useIntlayer(dictionaryKey, locale);
|
|
36
|
-
return createDictionaryTranslator(locale, content, keyPrefix);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
//#endregion
|
|
40
|
-
export { useTranslations };
|
|
41
|
-
//# sourceMappingURL=useTranslations.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useTranslations.mjs","names":[],"sources":["../../../src/react-server/useTranslations.ts"],"sourcesContent":["import type { DictionaryKeys } from '@intlayer/types/module_augmentation';\nimport {\n createDictionaryTranslator,\n type LooseTranslateFunction,\n type TranslateFunction,\n type TranslateFunctionForNamespace,\n} from '@intlayer/use-intl';\nimport { useIntlayer } from 'next-intlayer/server';\nimport { resolveServerLocale } from './resolveLocale';\n\ntype UseTranslations = {\n <N extends DictionaryKeys>(namespace: N): TranslateFunction<N>;\n <N extends `${string}.${string}`>(\n namespace: N\n ): TranslateFunctionForNamespace<N>;\n (): LooseTranslateFunction;\n};\n\n/** Splits `'about.counter'` into the dictionary key and its key prefix. */\nconst splitNamespace = (namespace: string): [string, string | undefined] => {\n const dotPosition = namespace.indexOf('.');\n if (dotPosition === -1) return [namespace, undefined];\n return [namespace.slice(0, dotPosition), namespace.slice(dotPosition + 1)];\n};\n\n/**\n * Server counterpart of `useTranslations`.\n *\n * next-intl's `useTranslations` is isomorphic — the same component code runs in\n * a Server or a Client Component — so the adapter has to be too. Without this\n * every component calling it is forced across the client boundary, which drags\n * its dictionary into a client chunk that Next shares across every locale.\n *\n * The optimize pass normally rewrites these calls to `useDictionary` with the\n * dictionary inlined; this runtime path covers the calls it could not resolve\n * statically (a dynamic namespace, or an unoptimized build).\n */\nexport const useTranslations = ((namespace?: string) => {\n const locale = resolveServerLocale();\n\n if (!namespace) {\n // Root scope: the first segment of each message id names the dictionary,\n // so the lookup can only happen per call.\n const rootTranslator = (key: string, values?: Record<string, unknown>) => {\n const [dictionaryKey, keyPrefix] = splitNamespace(key);\n const content = useIntlayer(dictionaryKey as never, locale as never);\n const translate = createDictionaryTranslator(locale, content, undefined);\n return translate(keyPrefix ?? '', values as never);\n };\n return rootTranslator as unknown as LooseTranslateFunction;\n }\n\n const [dictionaryKey, keyPrefix] = splitNamespace(namespace);\n const content = useIntlayer(dictionaryKey as never, locale as never);\n\n return createDictionaryTranslator(locale, content, keyPrefix);\n}) as UseTranslations;\n"],"mappings":";;;;;;AAmBA,MAAM,kBAAkB,cAAoD;CAC1E,MAAM,cAAc,UAAU,QAAQ,GAAG;CACzC,IAAI,gBAAgB,IAAI,OAAO,CAAC,WAAW,MAAS;CACpD,OAAO,CAAC,UAAU,MAAM,GAAG,WAAW,GAAG,UAAU,MAAM,cAAc,CAAC,CAAC;AAC3E;;;;;;;;;;;;;AAcA,MAAa,oBAAoB,cAAuB;CACtD,MAAM,SAAS,oBAAoB;CAEnC,IAAI,CAAC,WAAW;EAGd,MAAM,kBAAkB,KAAa,WAAqC;GACxE,MAAM,CAAC,eAAe,aAAa,eAAe,GAAG;GACrD,MAAM,UAAU,YAAY,eAAwB,MAAe;GAEnE,OADkB,2BAA2B,QAAQ,SAAS,MAC/C,CAAC,CAAC,aAAa,IAAI,MAAe;EACnD;EACA,OAAO;CACT;CAEA,MAAM,CAAC,eAAe,aAAa,eAAe,SAAS;CAC3D,MAAM,UAAU,YAAY,eAAwB,MAAe;CAEnE,OAAO,2BAA2B,QAAQ,SAAS,SAAS;AAC9D"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { log } from "@intlayer/config/built";
|
|
2
|
-
import { CYAN } from "@intlayer/config/colors";
|
|
3
|
-
import { colorize, getAppLogger } from "@intlayer/config/logger";
|
|
4
|
-
|
|
5
|
-
//#region src/warnUnsupported.ts
|
|
6
|
-
/**
|
|
7
|
-
* Warns, in development only, that a `next-intl` API is a no-op under the
|
|
8
|
-
* intlayer adapter.
|
|
9
|
-
*
|
|
10
|
-
* The `NODE_ENV` check is what keeps `@intlayer/config`'s logger and its ANSI
|
|
11
|
-
* colour table — around 6 KB — out of production bundles: with the branch
|
|
12
|
-
* folded away nothing references the imports any more and they are shaken out.
|
|
13
|
-
* That only works while `process.env.NODE_ENV` survives this package's own
|
|
14
|
-
* build and reaches the consuming app's bundler, which is why `tsdown.config.ts`
|
|
15
|
-
* pins `platform: 'neutral'`.
|
|
16
|
-
*
|
|
17
|
-
* @param api - Name of the shimmed `next-intl` export, e.g. `getMessages`.
|
|
18
|
-
* @param reason - What the developer should do instead.
|
|
19
|
-
*/
|
|
20
|
-
const warnUnsupported = (api, reason) => {
|
|
21
|
-
if (process.env.NODE_ENV !== "development") return;
|
|
22
|
-
getAppLogger({ log })(`${colorize(api, CYAN)} ${reason}`);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
//#endregion
|
|
26
|
-
export { warnUnsupported };
|
|
27
|
-
//# sourceMappingURL=warnUnsupported.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"warnUnsupported.mjs","names":[],"sources":["../../src/warnUnsupported.ts"],"sourcesContent":["import { log } from '@intlayer/config/built';\nimport { CYAN } from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\n\n/**\n * Warns, in development only, that a `next-intl` API is a no-op under the\n * intlayer adapter.\n *\n * The `NODE_ENV` check is what keeps `@intlayer/config`'s logger and its ANSI\n * colour table — around 6 KB — out of production bundles: with the branch\n * folded away nothing references the imports any more and they are shaken out.\n * That only works while `process.env.NODE_ENV` survives this package's own\n * build and reaches the consuming app's bundler, which is why `tsdown.config.ts`\n * pins `platform: 'neutral'`.\n *\n * @param api - Name of the shimmed `next-intl` export, e.g. `getMessages`.\n * @param reason - What the developer should do instead.\n */\nexport const warnUnsupported = (api: string, reason: string): void => {\n if (process.env.NODE_ENV !== 'development') return;\n\n getAppLogger({ log })(`${colorize(api, CYAN)} ${reason}`);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,MAAa,mBAAmB,KAAa,WAAyB;CACpE,IAAI,QAAQ,IAAI,aAAa,eAAe;CAE5C,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS,KAAK,IAAI,EAAE,GAAG,QAAQ;AAC1D"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
//#region src/react-server/helpers.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Server counterparts of use-intl's ambient hooks. They mirror the client
|
|
4
|
-
* versions' signatures so the same component code type-checks on both sides.
|
|
5
|
-
*/
|
|
6
|
-
export declare const useFormatter: typeof import('@intlayer/use-intl').useFormatter;
|
|
7
|
-
/** Current time on the server render. */
|
|
8
|
-
export declare const useNow: typeof import('@intlayer/use-intl').useNow;
|
|
9
|
-
/** Time zone used by the formatters; UTC unless the app overrides it. */
|
|
10
|
-
export declare const useTimeZone: typeof import('@intlayer/use-intl').useTimeZone;
|
|
11
|
-
//#endregion
|
|
12
|
-
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","names":[],"sources":["../../../src/react-server/helpers.ts"],"mappings":";;;;;qBAOa,kDAAkD;;qBAIlD,4CAA4C;;qBAI5C,iDAAiD"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { NextIntlClientProvider, NextIntlClientProviderProps } from "../client/NextIntlClientProvider.js";
|
|
2
|
-
import { Routing, defineRouting } from "../routing.js";
|
|
3
|
-
import { useFormatter, useNow, useTimeZone } from "./helpers.js";
|
|
4
|
-
import { useDictionary } from "./useDictionary.js";
|
|
5
|
-
import { useDictionaryDynamic } from "./useDictionaryDynamic.js";
|
|
6
|
-
import { useLocale } from "./useLocale.js";
|
|
7
|
-
import { useTranslations } from "./useTranslations.js";
|
|
8
|
-
import { IntlError, IntlErrorCode, createFormatter, createTranslator, hasLocale, initializeConfig, useMessages } from "@intlayer/use-intl";
|
|
9
|
-
export { IntlError, IntlErrorCode, NextIntlClientProvider, type NextIntlClientProviderProps, type Routing, createFormatter, createTranslator, defineRouting, hasLocale, initializeConfig, useDictionary, useDictionaryDynamic, useFormatter, useLocale, useMessages, useNow, useTimeZone, useTranslations };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
-
//#region src/react-server/resolveLocale.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* Locale for a synchronous server hook, resolved the same way `getLocale()`
|
|
5
|
-
* resolves it — so server-rendered content and the client provider never
|
|
6
|
-
* disagree about which locale the request is in.
|
|
7
|
-
*
|
|
8
|
-
* 1. The locale forwarded through `setRequestLocale(locale)` (the `[locale]`
|
|
9
|
-
* route segment), which is next-intl's source of truth for URL routing.
|
|
10
|
-
* 2. Otherwise Intlayer's ambient locale (server context, then the request).
|
|
11
|
-
*/
|
|
12
|
-
export declare const resolveServerLocale: () => LocalesValues;
|
|
13
|
-
//#endregion
|
|
14
|
-
//# sourceMappingURL=resolveLocale.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveLocale.d.ts","names":[],"sources":["../../../src/react-server/resolveLocale.ts"],"mappings":";;;;;;;;;;;qBAaa,2BAA0B"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { DictionaryKeys } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import { ScopedTranslateFunction, TranslateFunction } from "@intlayer/use-intl";
|
|
3
|
-
import { Dictionary } from "@intlayer/types/dictionary";
|
|
4
|
-
//#region src/react-server/useDictionary.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Overload set mirroring the client `useDictionary` exactly, so the optimize
|
|
7
|
-
* pass can emit the same call shape whichever side of the boundary the
|
|
8
|
-
* component ends up on.
|
|
9
|
-
*/
|
|
10
|
-
type UseDictionary = {
|
|
11
|
-
<T extends Dictionary>(dictionary: T): TranslateFunction<T['key'] & DictionaryKeys>;
|
|
12
|
-
<T extends Dictionary, Prefix extends string>(dictionary: T, namespacePrefix: Prefix): ScopedTranslateFunction<T['key'] & DictionaryKeys, Prefix>;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Server counterpart of `@intlayer/use-intl`'s `useDictionary`.
|
|
16
|
-
*
|
|
17
|
-
* The optimize pass rewrites every `useTranslations(...)` call to this helper
|
|
18
|
-
* with the dictionary pre-imported. Resolving it here — rather than in a client
|
|
19
|
-
* component — keeps the dictionary out of the client bundle entirely: the
|
|
20
|
-
* server renders the text and only the rendered output crosses the boundary.
|
|
21
|
-
*/
|
|
22
|
-
export declare const useDictionary: UseDictionary;
|
|
23
|
-
//#endregion
|
|
24
|
-
//# sourceMappingURL=useDictionary.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/react-server/useDictionary.ts"],"mappings":";;;;;;;;;KAkBK;GACF,UAAU,YACT,YAAY,IACX,kBAAkB,WAAW;GAC/B,UAAU,YAAY,uBACrB,YAAY,GACZ,iBAAiB,SAChB,wBAAwB,WAAW,gBAAgB;;;;;;;;;;qBAW3C,eAYP"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { DictionaryKeys } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import { ScopedTranslateFunction, TranslateFunction } from "@intlayer/use-intl";
|
|
3
|
-
import { Dictionary } from "@intlayer/types/dictionary";
|
|
4
|
-
//#region src/react-server/useDictionaryDynamic.d.ts
|
|
5
|
-
type UseDictionaryDynamic = {
|
|
6
|
-
<T extends Dictionary, K extends DictionaryKeys>(dictionaryPromise: Record<string, () => Promise<T>>, key: K): TranslateFunction<K>;
|
|
7
|
-
<T extends Dictionary, K extends DictionaryKeys, Prefix extends string>(dictionaryPromise: Record<string, () => Promise<T>>, key: K, namespacePrefix: Prefix): ScopedTranslateFunction<K, Prefix>;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Server counterpart of `useDictionaryDynamic`, emitted by the optimize pass
|
|
11
|
-
* for dictionaries on the per-locale loader.
|
|
12
|
-
*/
|
|
13
|
-
export declare const useDictionaryDynamic: UseDictionaryDynamic;
|
|
14
|
-
//#endregion
|
|
15
|
-
//# sourceMappingURL=useDictionaryDynamic.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/react-server/useDictionaryDynamic.ts"],"mappings":";;;;KAaK;GACF,UAAU,YAAY,UAAU,gBAC/B,mBAAmB,qBAAqB,QAAQ,KAChD,KAAK,IACJ,kBAAkB;GACpB,UAAU,YAAY,UAAU,gBAAgB,uBAC/C,mBAAmB,qBAAqB,QAAQ,KAChD,KAAK,GACL,iBAAiB,SAChB,wBAAwB,GAAG;;;;;;qBAOnB,sBAiBP"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { useLocale as useLocale$1 } from "next-intl";
|
|
2
|
-
//#region src/react-server/useLocale.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* Server counterpart of `useLocale`, resolved from the `[locale]` route segment
|
|
5
|
-
* forwarded through `setRequestLocale` when the app provides one.
|
|
6
|
-
*/
|
|
7
|
-
export declare const useLocale: typeof useLocale$1;
|
|
8
|
-
//#endregion
|
|
9
|
-
//# sourceMappingURL=useLocale.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.d.ts","names":[],"sources":["../../../src/react-server/useLocale.ts"],"mappings":";;;;;;qBAOa,kBAAkB"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { DictionaryKeys } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import { LooseTranslateFunction, TranslateFunction, TranslateFunctionForNamespace } from "@intlayer/use-intl";
|
|
3
|
-
//#region src/react-server/useTranslations.d.ts
|
|
4
|
-
type UseTranslations = {
|
|
5
|
-
<N extends DictionaryKeys>(namespace: N): TranslateFunction<N>;
|
|
6
|
-
<N extends `${string}.${string}`>(namespace: N): TranslateFunctionForNamespace<N>;
|
|
7
|
-
(): LooseTranslateFunction;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Server counterpart of `useTranslations`.
|
|
11
|
-
*
|
|
12
|
-
* next-intl's `useTranslations` is isomorphic — the same component code runs in
|
|
13
|
-
* a Server or a Client Component — so the adapter has to be too. Without this
|
|
14
|
-
* every component calling it is forced across the client boundary, which drags
|
|
15
|
-
* its dictionary into a client chunk that Next shares across every locale.
|
|
16
|
-
*
|
|
17
|
-
* The optimize pass normally rewrites these calls to `useDictionary` with the
|
|
18
|
-
* dictionary inlined; this runtime path covers the calls it could not resolve
|
|
19
|
-
* statically (a dynamic namespace, or an unoptimized build).
|
|
20
|
-
*/
|
|
21
|
-
export declare const useTranslations: UseTranslations;
|
|
22
|
-
//#endregion
|
|
23
|
-
//# sourceMappingURL=useTranslations.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useTranslations.d.ts","names":[],"sources":["../../../src/react-server/useTranslations.ts"],"mappings":";;;KAUK;GACF,UAAU,gBAAgB,WAAW,IAAI,kBAAkB;GAC3D,iCACC,WAAW,IACV,8BAA8B;MAC7B;;;;;;;;;;;;;;qBAsBO,iBAmBP"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
//#region src/warnUnsupported.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Warns, in development only, that a `next-intl` API is a no-op under the
|
|
4
|
-
* intlayer adapter.
|
|
5
|
-
*
|
|
6
|
-
* The `NODE_ENV` check is what keeps `@intlayer/config`'s logger and its ANSI
|
|
7
|
-
* colour table — around 6 KB — out of production bundles: with the branch
|
|
8
|
-
* folded away nothing references the imports any more and they are shaken out.
|
|
9
|
-
* That only works while `process.env.NODE_ENV` survives this package's own
|
|
10
|
-
* build and reaches the consuming app's bundler, which is why `tsdown.config.ts`
|
|
11
|
-
* pins `platform: 'neutral'`.
|
|
12
|
-
*
|
|
13
|
-
* @param api - Name of the shimmed `next-intl` export, e.g. `getMessages`.
|
|
14
|
-
* @param reason - What the developer should do instead.
|
|
15
|
-
*/
|
|
16
|
-
export declare const warnUnsupported: (api: string, reason: string) => void;
|
|
17
|
-
//#endregion
|
|
18
|
-
//# sourceMappingURL=warnUnsupported.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"warnUnsupported.d.ts","names":[],"sources":["../../src/warnUnsupported.ts"],"mappings":";;;;;;;;;;;;;;;qBAkBa,kBAAe,aAAe"}
|