@entifix/next-i18n 0.1.4 → 0.3.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/dist/server.d.ts CHANGED
@@ -5,7 +5,7 @@ import type { Namespace } from 'i18next';
5
5
  *
6
6
  * Read from a header rather than a route param — that is the trade the rewrite
7
7
  * strategy makes, and it is why the back-office route trees have no
8
- * `app/[locale]` segment. Falls back to the fleet default for paths the
8
+ * `app/[locale]` segment. Falls back to the host's default for paths the
9
9
  * middleware matcher skips (`/api/health`, `/api/config`), which have no
10
10
  * user-facing copy anyway.
11
11
  *
package/dist/server.js CHANGED
@@ -1,4 +1,4 @@
1
- import { DEFAULT_LOCALE, isLocale, LOCALE_HEADER } from '@entifix/core';
1
+ import { defaultLocale, isLocale, LOCALE_HEADER } from '@entifix/core';
2
2
  import { createI18n } from '@entifix/i18n';
3
3
  import { headers } from 'next/headers';
4
4
  /**
@@ -6,7 +6,7 @@ import { headers } from 'next/headers';
6
6
  *
7
7
  * Read from a header rather than a route param — that is the trade the rewrite
8
8
  * strategy makes, and it is why the back-office route trees have no
9
- * `app/[locale]` segment. Falls back to the fleet default for paths the
9
+ * `app/[locale]` segment. Falls back to the host's default for paths the
10
10
  * middleware matcher skips (`/api/health`, `/api/config`), which have no
11
11
  * user-facing copy anyway.
12
12
  *
@@ -18,7 +18,7 @@ import { headers } from 'next/headers';
18
18
  * {@link getServerTFor}.
19
19
  */ export async function getRequestLocale() {
20
20
  const value = (await headers()).get(LOCALE_HEADER);
21
- return isLocale(value) ? value : DEFAULT_LOCALE;
21
+ return isLocale(value) ? value : defaultLocale();
22
22
  }
23
23
  /**
24
24
  * The request-free counterpart of {@link getServerT}, for a locale the caller
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server.ts"],"sourcesContent":["import {\n DEFAULT_LOCALE,\n isLocale,\n type Locale,\n LOCALE_HEADER,\n} from '@entifix/core';\nimport { createI18n } from '@entifix/i18n';\nimport type { Namespace } from 'i18next';\nimport { headers } from 'next/headers';\n\n/**\n * The locale the middleware resolved for this request.\n *\n * Read from a header rather than a route param — that is the trade the rewrite\n * strategy makes, and it is why the back-office route trees have no\n * `app/[locale]` segment. Falls back to the fleet default for paths the\n * middleware matcher skips (`/api/health`, `/api/config`), which have no\n * user-facing copy anyway.\n *\n * A header is a **dynamic** request input, so a page that calls this — or\n * {@link getServerT}, which does — can never be prerendered. That is the right\n * trade for an auth-gated app whose every response is personal anyway, and the\n * wrong one for a public storefront: marketplace-app therefore carries a real\n * `[locale]` segment and reads its locale from the route param, through\n * {@link getServerTFor}.\n */\nexport async function getRequestLocale(): Promise<Locale> {\n const value = (await headers()).get(LOCALE_HEADER);\n return isLocale(value) ? value : DEFAULT_LOCALE;\n}\n\n/**\n * The request-free counterpart of {@link getServerT}, for a locale the caller\n * already holds — a route param, typically.\n *\n * Re-exported rather than defined here so it sits next to `getServerT` at an\n * app's call sites while still being reachable from packages that may not\n * depend on this one: the shells share T4, the tier register declares no edge\n * between them, and the storefront shell is precisely the caller that needs it. The implementation\n * lives in `@entifix/i18n`.\n */\nexport { getServerTFor } from '@entifix/i18n';\n\n/**\n * A translate function for a server component. A fresh instance per request,\n * because a module-level singleton would let one visitor's locale leak into\n * another's markup under concurrent rendering.\n */\nexport async function getServerT<N extends Namespace>(ns?: N) {\n const locale = await getRequestLocale();\n return createI18n(locale).getFixedT(locale, ns ?? null);\n}\n\nexport type TranslateKey = (\n key: string,\n params?: Record<string, unknown>,\n) => string;\n\n/**\n * The server counterpart of the controls package's `useTranslateKey`: resolves\n * keys that are only known at runtime — nav labels held in a route table, an\n * entity's `labelKey`.\n *\n * Separate from {@link getServerT}, which stays strict. This is the one place\n * the typed-key guarantee is traded away on the server, and authored copy must\n * keep going through `getServerT` so a typo stays a compile error.\n */\nexport async function getServerTranslateKey<N extends Namespace>(\n ns?: N,\n): Promise<TranslateKey> {\n const t = await getServerT(ns);\n return t as unknown as TranslateKey;\n}\n"],"names":["DEFAULT_LOCALE","isLocale","LOCALE_HEADER","createI18n","headers","getRequestLocale","value","get","getServerTFor","getServerT","ns","locale","getFixedT","getServerTranslateKey","t"],"mappings":"AAAA,SACEA,cAAc,EACdC,QAAQ,EAERC,aAAa,QACR,gBAAgB;AACvB,SAASC,UAAU,QAAQ,gBAAgB;AAE3C,SAASC,OAAO,QAAQ,eAAe;AAEvC;;;;;;;;;;;;;;;CAeC,GACD,OAAO,eAAeC;IACpB,MAAMC,QAAQ,AAAC,CAAA,MAAMF,SAAQ,EAAGG,GAAG,CAACL;IACpC,OAAOD,SAASK,SAASA,QAAQN;AACnC;AAEA;;;;;;;;;CASC,GACD,SAASQ,aAAa,QAAQ,gBAAgB;AAE9C;;;;CAIC,GACD,OAAO,eAAeC,WAAgCC,EAAM;IAC1D,MAAMC,SAAS,MAAMN;IACrB,OAAOF,WAAWQ,QAAQC,SAAS,CAACD,QAAQD,aAAAA,KAAM;AACpD;AAOA;;;;;;;;CAQC,GACD,OAAO,eAAeG,sBACpBH,EAAM;IAEN,MAAMI,IAAI,MAAML,WAAWC;IAC3B,OAAOI;AACT"}
1
+ {"version":3,"sources":["../src/server.ts"],"sourcesContent":["import {\n defaultLocale,\n isLocale,\n type Locale,\n LOCALE_HEADER,\n} from '@entifix/core';\nimport { createI18n } from '@entifix/i18n';\nimport type { Namespace } from 'i18next';\nimport { headers } from 'next/headers';\n\n/**\n * The locale the middleware resolved for this request.\n *\n * Read from a header rather than a route param — that is the trade the rewrite\n * strategy makes, and it is why the back-office route trees have no\n * `app/[locale]` segment. Falls back to the host's default for paths the\n * middleware matcher skips (`/api/health`, `/api/config`), which have no\n * user-facing copy anyway.\n *\n * A header is a **dynamic** request input, so a page that calls this — or\n * {@link getServerT}, which does — can never be prerendered. That is the right\n * trade for an auth-gated app whose every response is personal anyway, and the\n * wrong one for a public storefront: marketplace-app therefore carries a real\n * `[locale]` segment and reads its locale from the route param, through\n * {@link getServerTFor}.\n */\nexport async function getRequestLocale(): Promise<Locale> {\n const value = (await headers()).get(LOCALE_HEADER);\n return isLocale(value) ? value : defaultLocale();\n}\n\n/**\n * The request-free counterpart of {@link getServerT}, for a locale the caller\n * already holds — a route param, typically.\n *\n * Re-exported rather than defined here so it sits next to `getServerT` at an\n * app's call sites while still being reachable from packages that may not\n * depend on this one: the shells share T4, the tier register declares no edge\n * between them, and the storefront shell is precisely the caller that needs it. The implementation\n * lives in `@entifix/i18n`.\n */\nexport { getServerTFor } from '@entifix/i18n';\n\n/**\n * A translate function for a server component. A fresh instance per request,\n * because a module-level singleton would let one visitor's locale leak into\n * another's markup under concurrent rendering.\n */\nexport async function getServerT<N extends Namespace>(ns?: N) {\n const locale = await getRequestLocale();\n return createI18n(locale).getFixedT(locale, ns ?? null);\n}\n\nexport type TranslateKey = (\n key: string,\n params?: Record<string, unknown>,\n) => string;\n\n/**\n * The server counterpart of the controls package's `useTranslateKey`: resolves\n * keys that are only known at runtime — nav labels held in a route table, an\n * entity's `labelKey`.\n *\n * Separate from {@link getServerT}, which stays strict. This is the one place\n * the typed-key guarantee is traded away on the server, and authored copy must\n * keep going through `getServerT` so a typo stays a compile error.\n */\nexport async function getServerTranslateKey<N extends Namespace>(\n ns?: N,\n): Promise<TranslateKey> {\n const t = await getServerT(ns);\n return t as unknown as TranslateKey;\n}\n"],"names":["defaultLocale","isLocale","LOCALE_HEADER","createI18n","headers","getRequestLocale","value","get","getServerTFor","getServerT","ns","locale","getFixedT","getServerTranslateKey","t"],"mappings":"AAAA,SACEA,aAAa,EACbC,QAAQ,EAERC,aAAa,QACR,gBAAgB;AACvB,SAASC,UAAU,QAAQ,gBAAgB;AAE3C,SAASC,OAAO,QAAQ,eAAe;AAEvC;;;;;;;;;;;;;;;CAeC,GACD,OAAO,eAAeC;IACpB,MAAMC,QAAQ,AAAC,CAAA,MAAMF,SAAQ,EAAGG,GAAG,CAACL;IACpC,OAAOD,SAASK,SAASA,QAAQN;AACnC;AAEA;;;;;;;;;CASC,GACD,SAASQ,aAAa,QAAQ,gBAAgB;AAE9C;;;;CAIC,GACD,OAAO,eAAeC,WAAgCC,EAAM;IAC1D,MAAMC,SAAS,MAAMN;IACrB,OAAOF,WAAWQ,QAAQC,SAAS,CAACD,QAAQD,aAAAA,KAAM;AACpD;AAOA;;;;;;;;CAQC,GACD,OAAO,eAAeG,sBACpBH,EAAM;IAEN,MAAMI,IAAI,MAAML,WAAWC;IAC3B,OAAOI;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entifix/next-i18n",
3
- "version": "0.1.4",
3
+ "version": "0.3.0",
4
4
  "description": "Next.js locale routing and server-side translation for @entifix/i18n, with the locale carried in the URL prefix.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -18,13 +18,11 @@
18
18
  "exports": {
19
19
  "./package.json": "./package.json",
20
20
  ".": {
21
- "@entifix/source": "./src/index.ts",
22
21
  "types": "./dist/index.d.ts",
23
22
  "import": "./dist/index.js",
24
23
  "default": "./dist/index.js"
25
24
  },
26
25
  "./server": {
27
- "@entifix/source": "./src/server.ts",
28
26
  "types": "./dist/server.d.ts",
29
27
  "import": "./dist/server.js",
30
28
  "default": "./dist/server.js"
@@ -58,8 +56,8 @@
58
56
  },
59
57
  "dependencies": {
60
58
  "@swc/helpers": "0.5.23",
61
- "@entifix/i18n": "0.1.4",
62
- "@entifix/core": "0.1.4"
59
+ "@entifix/core": "0.3.0",
60
+ "@entifix/i18n": "0.3.0"
63
61
  },
64
62
  "peerDependencies": {
65
63
  "next": ">=16",