next-intl 3.2.3 โ 3.2.5
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 +1 -1
- package/dist/development/middleware/middleware.js +3 -3
- package/dist/development/middleware/utils.js +2 -10
- package/dist/development/server/react-client/index.js +5 -1
- package/dist/development/server/react-server/createRequestConfig.js +0 -1
- package/dist/development/server/react-server/getTranslations.js +4 -0
- package/dist/esm/middleware/middleware.js +1 -1
- package/dist/esm/middleware/utils.js +1 -1
- package/dist/esm/server/react-client/index.js +1 -1
- package/dist/production/middleware/middleware.js +1 -1
- package/dist/production/middleware/utils.js +1 -1
- package/dist/production/server/react-client/index.js +1 -1
- package/dist/types/src/middleware/utils.d.ts +0 -1
- package/dist/types/src/server/react-client/index.d.ts +1 -50
- package/dist/types/src/server/react-server/getConfig.d.ts +6 -21
- package/dist/types/src/server/react-server/getFormatter.d.ts +2 -6
- package/dist/types/src/server/react-server/getMessages.d.ts +2 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ Internationalization is an essential part of the user experience. next-intl give
|
|
|
24
24
|
- ๐ **ICU message syntax**: Localize your messages with interpolation, cardinal & ordinal plurals, enum-based label selection and rich text.
|
|
25
25
|
- ๐
**Dates, times & numbers**: Apply appropriate formatting without worrying about server/client differences like time zones.
|
|
26
26
|
- โ
**Type-safe**: Speed up development with autocompletion for message keys and catch typos early with compile-time checks.
|
|
27
|
-
- ๐ก **Hooks-
|
|
27
|
+
- ๐ก **Hooks-based API**: Learn a single API that can be used across your code base to turn translations into plain strings or rich text.
|
|
28
28
|
- ๐ **Next.js-native and performance-obsessed**: App Router, Server Components, static renderingโpick the right tool for the right job, next-intl works everywhere.
|
|
29
29
|
- โ๏ธ **Internationalized routing**: Provide unique pathnames per language and optionally localize pathnames for search engine optimization.
|
|
30
30
|
|
|
@@ -51,8 +51,8 @@ function createMiddleware(config) {
|
|
|
51
51
|
const bestMatchingDomain = utils.getBestMatchingDomain(domain, locale, domainConfigs);
|
|
52
52
|
if (bestMatchingDomain) {
|
|
53
53
|
redirectDomain = bestMatchingDomain.domain;
|
|
54
|
-
if (bestMatchingDomain.defaultLocale === locale && configWithDefaults.localePrefix === 'as-needed') {
|
|
55
|
-
urlObj.pathname = urlObj.pathname
|
|
54
|
+
if (bestMatchingDomain.defaultLocale === locale && configWithDefaults.localePrefix === 'as-needed' && urlObj.pathname.startsWith("/".concat(locale))) {
|
|
55
|
+
urlObj.pathname = utils.getNormalizedPathname(urlObj.pathname, configWithDefaults.locales);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -96,7 +96,7 @@ function createMiddleware(config) {
|
|
|
96
96
|
} else {
|
|
97
97
|
const internalPathWithSearch = utils.getPathWithSearch(pathname, request.nextUrl.search);
|
|
98
98
|
if (hasLocalePrefix) {
|
|
99
|
-
const basePath = utils.
|
|
99
|
+
const basePath = utils.getNormalizedPathname(utils.getPathWithSearch(normalizedPathname, request.nextUrl.search), configWithDefaults.locales);
|
|
100
100
|
if (configWithDefaults.localePrefix === 'never') {
|
|
101
101
|
response = redirect(basePath);
|
|
102
102
|
} else if (pathLocale === locale) {
|
|
@@ -46,8 +46,8 @@ function getNormalizedPathname(pathname, locales) {
|
|
|
46
46
|
if (!pathname.endsWith('/')) {
|
|
47
47
|
pathname += '/';
|
|
48
48
|
}
|
|
49
|
-
const match = pathname.match("^/(".concat(locales.join('|'), ")(.*)"));
|
|
50
|
-
let result = match ? match[2] : pathname;
|
|
49
|
+
const match = pathname.match("^/(".concat(locales.join('|'), ")/(.*)"));
|
|
50
|
+
let result = match ? '/' + match[2] : pathname;
|
|
51
51
|
|
|
52
52
|
// Remove trailing slash
|
|
53
53
|
if (result.endsWith('/') && result !== '/') {
|
|
@@ -60,13 +60,6 @@ function getKnownLocaleFromPathname(pathname, locales) {
|
|
|
60
60
|
const pathLocale = locales.includes(pathLocaleCandidate) ? pathLocaleCandidate : undefined;
|
|
61
61
|
return pathLocale;
|
|
62
62
|
}
|
|
63
|
-
function getBasePath(pathname, pathLocale) {
|
|
64
|
-
let result = pathname.replace("/".concat(pathLocale), '');
|
|
65
|
-
if (!result.startsWith('/')) {
|
|
66
|
-
result = "/".concat(result);
|
|
67
|
-
}
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
63
|
function getRouteParams(template, pathname) {
|
|
71
64
|
const regex = utils.templateToRegex(template);
|
|
72
65
|
const match = regex.exec(pathname);
|
|
@@ -138,7 +131,6 @@ function getBestMatchingDomain(curHostDomain, locale, domainConfigs) {
|
|
|
138
131
|
|
|
139
132
|
exports.formatPathname = formatPathname;
|
|
140
133
|
exports.formatTemplatePathname = formatTemplatePathname;
|
|
141
|
-
exports.getBasePath = getBasePath;
|
|
142
134
|
exports.getBestMatchingDomain = getBestMatchingDomain;
|
|
143
135
|
exports.getHost = getHost;
|
|
144
136
|
exports.getInternalTemplate = getInternalTemplate;
|
|
@@ -21,9 +21,13 @@ function getRequestConfig() {
|
|
|
21
21
|
const getFormatter = notSupported('getFormatter');
|
|
22
22
|
const getNow = notSupported('getNow');
|
|
23
23
|
const getTimeZone = notSupported('getTimeZone');
|
|
24
|
-
const getTranslations = notSupported('getTranslations');
|
|
25
24
|
const getMessages = notSupported('getMessages');
|
|
26
25
|
const getLocale = notSupported('getLocale');
|
|
26
|
+
|
|
27
|
+
// The type of `getTranslations` is not assigned here because it
|
|
28
|
+
// causes a type error. The types use the `react-server` entry
|
|
29
|
+
// anyway, therefore this is irrelevant.
|
|
30
|
+
const getTranslations = notSupported('getTranslations');
|
|
27
31
|
const unstable_setRequestLocale = notSupported('unstable_setRequestLocale');
|
|
28
32
|
|
|
29
33
|
exports.getFormatter = getFormatter;
|
|
@@ -8,7 +8,6 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
8
8
|
|
|
9
9
|
var getRuntimeConfig__default = /*#__PURE__*/_interopDefault(getRuntimeConfig);
|
|
10
10
|
|
|
11
|
-
// @ts-expect-error
|
|
12
11
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
13
12
|
|
|
14
13
|
Object.defineProperty(exports, 'default', {
|
|
@@ -10,6 +10,10 @@ var getLocale = require('./getLocale.js');
|
|
|
10
10
|
// Maintainer note: `getTranslations` has two different call signatures.
|
|
11
11
|
// We need to define these with function overloads, otherwise TypeScript
|
|
12
12
|
// messes up the return type.
|
|
13
|
+
|
|
14
|
+
// CALL SIGNATURE 1: `getTranslations(namespace)`
|
|
15
|
+
// CALL SIGNATURE 2: `getTranslations({locale, namespace})`
|
|
16
|
+
// IMPLEMENTATION
|
|
13
17
|
async function getTranslations(namespaceOrOpts) {
|
|
14
18
|
let namespace;
|
|
15
19
|
let locale;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NextResponse as e}from"next/server";import{COOKIE_LOCALE_NAME as o,HEADER_LOCALE_NAME as l}from"../shared/constants.js";import{matchesPathname as
|
|
1
|
+
import{NextResponse as e}from"next/server";import{COOKIE_LOCALE_NAME as o,HEADER_LOCALE_NAME as l}from"../shared/constants.js";import{matchesPathname as t}from"../shared/utils.js";import n from"./getAlternateLinksHeaderValue.js";import a from"./resolveLocale.js";import{isLocaleSupportedOnDomain as r,getNormalizedPathname as i,getKnownLocaleFromPathname as s,getInternalTemplate as c,formatTemplatePathname as d,getPathWithSearch as f,getBestMatchingDomain as u}from"./utils.js";function m(m){const v=function(e){var o,l,t;return{...e,alternateLinks:null===(o=e.alternateLinks)||void 0===o||o,localePrefix:null!==(l=e.localePrefix)&&void 0!==l?l:"always",localeDetection:null===(t=e.localeDetection)||void 0===t||t}}(m);return function(m){var h,p;const{domain:x,locale:L}=a(v,m.headers,m.cookies,m.nextUrl.pathname),P=v.localeDetection&&(null===(h=m.cookies.get(o))||void 0===h?void 0:h.value)!==L,U=x?x.defaultLocale===L:L===v.defaultLocale,g=(null===(p=v.domains)||void 0===p?void 0:p.filter((e=>r(L,e))))||[],k=null!=v.domains&&!x;function w(o){return e.rewrite(new URL(o,m.url),function(){const e=new Headers(m.headers);return e.set(l,L),{request:{headers:e}}}())}function j(o,l){const t=new URL(o,m.url);if(g.length>0&&!l){const e=u(x,L,g);e&&(l=e.domain,e.defaultLocale===L&&"as-needed"===v.localePrefix&&t.pathname.startsWith("/".concat(L))&&(t.pathname=i(t.pathname,v.locales)))}var n;l&&(t.protocol=null!==(n=m.headers.get("x-forwarded-proto"))&&void 0!==n?n:m.nextUrl.protocol,t.port="",t.host=l);return e.redirect(t.toString())}const y=i(m.nextUrl.pathname,v.locales),D=s(m.nextUrl.pathname,v.locales),q=null!=D;let A,H,R=m.nextUrl.pathname;if(v.pathnames){let e;if([e=L,H]=c(v.pathnames,y),H){const o=v.pathnames[H],l="string"==typeof o?o:o[L];if(t(l,y))R=d(y,l,H,D);else{const t=v.defaultLocale===L||(null==x?void 0:x.defaultLocale)===L;A=j(f(d(y,"string"==typeof o?o:o[e],l,D||!t?L:void 0),m.nextUrl.search))}}}if(!A)if("/"===R){const e=f("/".concat(L),m.nextUrl.search);A="never"===v.localePrefix||U&&"as-needed"===v.localePrefix?w(e):j(e)}else{const e=f(R,m.nextUrl.search);if(q){const o=i(f(y,m.nextUrl.search),v.locales);if("never"===v.localePrefix)A=j(o);else if(D===L)if(U&&"as-needed"===v.localePrefix)A=j(o);else if(v.domains){const l=u(x,D,g);A=(null==x?void 0:x.domain)===(null==l?void 0:l.domain)||k?w(e):j(o,null==l?void 0:l.domain)}else A=w(e);else A=j("/".concat(L).concat(o))}else A="never"===v.localePrefix||U&&("as-needed"===v.localePrefix||v.domains)?w("/".concat(L).concat(e)):j("/".concat(L).concat(e))}var S;(P&&A.cookies.set(o,L,{sameSite:"strict",maxAge:31536e3}),"never"!==v.localePrefix&&v.alternateLinks&&v.locales.length>1)&&A.headers.set("Link",n({config:v,localizedPathnames:null!=H?null===(S=v.pathnames)||void 0===S?void 0:S[H]:void 0,request:m,resolvedLocale:L}));return A}}export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{matchesPathname as
|
|
1
|
+
import{matchesPathname as n,templateToRegex as e}from"../shared/utils.js";function t(n){return n.split("/")[1]}function o(e,t){for(const[o,l]of Object.entries(e))if("string"==typeof l){if(n(l,t))return[void 0,o]}else for(const[e,r]of Object.entries(l))if(n(r,t))return[e,o];return[void 0,void 0]}function l(n,e,t,o){const l=i(e,n);let r="";return o&&(r="/".concat(o)),r+=u(t,l),r.endsWith("/")&&(r=r.slice(0,-1)),r}function r(n,e){n.endsWith("/")||(n+="/");const t=n.match("^/(".concat(e.join("|"),")/(.*)"));let o=t?"/"+t[2]:n;return o.endsWith("/")&&"/"!==o&&(o=o.slice(0,-1)),o}function c(n,e){const o=t(n);return e.includes(o)?o:void 0}function i(n,t){const o=e(n).exec(t);if(!o)return;const l={};for(let e=1;e<o.length;e++){var r;const t=null===(r=n.match(/\[([^\]]+)\]/g))||void 0===r?void 0:r[e-1].replace(/[[\]]/g,"");t&&(l[t]=o[e])}return l}function u(n,e){if(!e)return n;let t=n=n.replaceAll("[[","[").replaceAll("]]","]");return Object.entries(e).forEach((n=>{let[e,o]=n;t=t.replace("[".concat(e,"]"),o)})),t}function s(n,e){let t=n;return e&&(t+=e),t}function f(n){var e,t;return null!==(e=null!==(t=n.get("x-forwarded-host"))&&void 0!==t?t:n.get("host"))&&void 0!==e?e:void 0}function a(n,e){return e.defaultLocale===n||!e.locales||e.locales.includes(n)}function d(n,e,t){let o;return n&&a(e,n)&&(o=n),o||(o=t.find((n=>n.defaultLocale===e))),o||(o=t.find((n=>null!=n.locales&&n.locales.includes(e)))),o||null!=(null==n?void 0:n.locales)||(o=n),o||(o=t.find((n=>!n.locales))),o}export{u as formatPathname,l as formatTemplatePathname,d as getBestMatchingDomain,f as getHost,o as getInternalTemplate,c as getKnownLocaleFromPathname,t as getLocaleFromPathname,r as getNormalizedPathname,s as getPathWithSearch,i as getRouteParams,a as isLocaleSupportedOnDomain};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){return()=>{throw new Error("`".concat(e,"` is not supported in Client Components."))}}function t(){return e("getRequestConfig")}const n=e("getFormatter"),o=e("getNow"),r=e("getTimeZone"),s=e("
|
|
1
|
+
function e(e){return()=>{throw new Error("`".concat(e,"` is not supported in Client Components."))}}function t(){return e("getRequestConfig")}const n=e("getFormatter"),o=e("getNow"),r=e("getTimeZone"),s=e("getMessages"),g=e("getLocale"),a=e("getTranslations"),i=e("unstable_setRequestLocale");export{n as getFormatter,g as getLocale,s as getMessages,o as getNow,t as getRequestConfig,r as getTimeZone,a as getTranslations,i as unstable_setRequestLocale};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/server"),t=require("../shared/constants.js"),a=require("../shared/utils.js"),n=require("./getAlternateLinksHeaderValue.js"),l=require("./resolveLocale.js"),o=require("./utils.js");exports.default=function(r){const i=function(e){var t,a,n;return{...e,alternateLinks:null===(t=e.alternateLinks)||void 0===t||t,localePrefix:null!==(a=e.localePrefix)&&void 0!==a?a:"always",localeDetection:null===(n=e.localeDetection)||void 0===n||n}}(r);return function(r){var s,c;const{domain:d,locale:u}=l.default(i,r.headers,r.cookies,r.nextUrl.pathname),h=i.localeDetection&&(null===(s=r.cookies.get(t.COOKIE_LOCALE_NAME))||void 0===s?void 0:s.value)!==u,f=d?d.defaultLocale===u:u===i.defaultLocale,m=(null===(c=i.domains)||void 0===c?void 0:c.filter((e=>o.isLocaleSupportedOnDomain(u,e))))||[],v=null!=i.domains&&!d;function p(a){return e.NextResponse.rewrite(new URL(a,r.url),function(){const e=new Headers(r.headers);return e.set(t.HEADER_LOCALE_NAME,u),{request:{headers:e}}}())}function x(t,a){const n=new URL(t,r.url);if(m.length>0&&!a){const e=o.getBestMatchingDomain(d,u,m);e&&(a=e.domain,e.defaultLocale===u&&"as-needed"===i.localePrefix&&
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/server"),t=require("../shared/constants.js"),a=require("../shared/utils.js"),n=require("./getAlternateLinksHeaderValue.js"),l=require("./resolveLocale.js"),o=require("./utils.js");exports.default=function(r){const i=function(e){var t,a,n;return{...e,alternateLinks:null===(t=e.alternateLinks)||void 0===t||t,localePrefix:null!==(a=e.localePrefix)&&void 0!==a?a:"always",localeDetection:null===(n=e.localeDetection)||void 0===n||n}}(r);return function(r){var s,c;const{domain:d,locale:u}=l.default(i,r.headers,r.cookies,r.nextUrl.pathname),h=i.localeDetection&&(null===(s=r.cookies.get(t.COOKIE_LOCALE_NAME))||void 0===s?void 0:s.value)!==u,f=d?d.defaultLocale===u:u===i.defaultLocale,m=(null===(c=i.domains)||void 0===c?void 0:c.filter((e=>o.isLocaleSupportedOnDomain(u,e))))||[],v=null!=i.domains&&!d;function p(a){return e.NextResponse.rewrite(new URL(a,r.url),function(){const e=new Headers(r.headers);return e.set(t.HEADER_LOCALE_NAME,u),{request:{headers:e}}}())}function x(t,a){const n=new URL(t,r.url);if(m.length>0&&!a){const e=o.getBestMatchingDomain(d,u,m);e&&(a=e.domain,e.defaultLocale===u&&"as-needed"===i.localePrefix&&n.pathname.startsWith("/".concat(u))&&(n.pathname=o.getNormalizedPathname(n.pathname,i.locales)))}var l;a&&(n.protocol=null!==(l=r.headers.get("x-forwarded-proto"))&&void 0!==l?l:r.nextUrl.protocol,n.port="",n.host=a);return e.NextResponse.redirect(n.toString())}const g=o.getNormalizedPathname(r.nextUrl.pathname,i.locales),P=o.getKnownLocaleFromPathname(r.nextUrl.pathname,i.locales),L=null!=P;let U,E,A=r.nextUrl.pathname;if(i.pathnames){let e;if([e=u,E]=o.getInternalTemplate(i.pathnames,g),E){const t=i.pathnames[E],n="string"==typeof t?t:t[u];if(a.matchesPathname(n,g))A=o.formatTemplatePathname(g,n,E,P);else{const a=i.defaultLocale===u||(null==d?void 0:d.defaultLocale)===u;U=x(o.getPathWithSearch(o.formatTemplatePathname(g,"string"==typeof t?t:t[e],n,P||!a?u:void 0),r.nextUrl.search))}}}if(!U)if("/"===A){const e=o.getPathWithSearch("/".concat(u),r.nextUrl.search);U="never"===i.localePrefix||f&&"as-needed"===i.localePrefix?p(e):x(e)}else{const e=o.getPathWithSearch(A,r.nextUrl.search);if(L){const t=o.getNormalizedPathname(o.getPathWithSearch(g,r.nextUrl.search),i.locales);if("never"===i.localePrefix)U=x(t);else if(P===u)if(f&&"as-needed"===i.localePrefix)U=x(t);else if(i.domains){const a=o.getBestMatchingDomain(d,P,m);U=(null==d?void 0:d.domain)===(null==a?void 0:a.domain)||v?p(e):x(t,null==a?void 0:a.domain)}else U=p(e);else U=x("/".concat(u).concat(t))}else U="never"===i.localePrefix||f&&("as-needed"===i.localePrefix||i.domains)?p("/".concat(u).concat(e)):x("/".concat(u).concat(e))}var O;(h&&U.cookies.set(t.COOKIE_LOCALE_NAME,u,{sameSite:"strict",maxAge:31536e3}),"never"!==i.localePrefix&&i.alternateLinks&&i.locales.length>1)&&U.headers.set("Link",n.default({config:i,localizedPathnames:null!=E?null===(O=i.pathnames)||void 0===O?void 0:O[E]:void 0,request:r,resolvedLocale:u}));return U}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/utils.js");function t(e){return e.split("/")[1]}function n(t,n){const o=e.templateToRegex(t).exec(n);if(!o)return;const r={};for(let e=1;e<o.length;e++){var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/utils.js");function t(e){return e.split("/")[1]}function n(t,n){const o=e.templateToRegex(t).exec(n);if(!o)return;const r={};for(let e=1;e<o.length;e++){var l;const n=null===(l=t.match(/\[([^\]]+)\]/g))||void 0===l?void 0:l[e-1].replace(/[[\]]/g,"");n&&(r[n]=o[e])}return r}function o(e,t){if(!t)return e;let n=e=e.replaceAll("[[","[").replaceAll("]]","]");return Object.entries(t).forEach((e=>{let[t,o]=e;n=n.replace("[".concat(t,"]"),o)})),n}function r(e,t){return t.defaultLocale===e||!t.locales||t.locales.includes(e)}exports.formatPathname=o,exports.formatTemplatePathname=function(e,t,r,l){const a=n(t,e);let c="";return l&&(c="/".concat(l)),c+=o(r,a),c.endsWith("/")&&(c=c.slice(0,-1)),c},exports.getBestMatchingDomain=function(e,t,n){let o;return e&&r(t,e)&&(o=e),o||(o=n.find((e=>e.defaultLocale===t))),o||(o=n.find((e=>null!=e.locales&&e.locales.includes(t)))),o||null!=(null==e?void 0:e.locales)||(o=e),o||(o=n.find((e=>!e.locales))),o},exports.getHost=function(e){var t,n;return null!==(t=null!==(n=e.get("x-forwarded-host"))&&void 0!==n?n:e.get("host"))&&void 0!==t?t:void 0},exports.getInternalTemplate=function(t,n){for(const[o,r]of Object.entries(t))if("string"==typeof r){const t=r;if(e.matchesPathname(t,n))return[void 0,o]}else for(const[t,l]of Object.entries(r))if(e.matchesPathname(l,n))return[t,o];return[void 0,void 0]},exports.getKnownLocaleFromPathname=function(e,n){const o=t(e);return n.includes(o)?o:void 0},exports.getLocaleFromPathname=t,exports.getNormalizedPathname=function(e,t){e.endsWith("/")||(e+="/");const n=e.match("^/(".concat(t.join("|"),")/(.*)"));let o=n?"/"+n[2]:e;return o.endsWith("/")&&"/"!==o&&(o=o.slice(0,-1)),o},exports.getPathWithSearch=function(e,t){let n=e;return t&&(n+=t),n},exports.getRouteParams=n,exports.isLocaleSupportedOnDomain=r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e){return()=>{throw new Error("`".concat(e,"` is not supported in Client Components."))}}Object.defineProperty(exports,"__esModule",{value:!0});const t=e("getFormatter"),o=e("getNow"),s=e("getTimeZone"),r=e("
|
|
1
|
+
"use strict";function e(e){return()=>{throw new Error("`".concat(e,"` is not supported in Client Components."))}}Object.defineProperty(exports,"__esModule",{value:!0});const t=e("getFormatter"),o=e("getNow"),s=e("getTimeZone"),r=e("getMessages"),n=e("getLocale"),g=e("getTranslations"),a=e("unstable_setRequestLocale");exports.getFormatter=t,exports.getLocale=n,exports.getMessages=r,exports.getNow=o,exports.getRequestConfig=function(){return e("getRequestConfig")},exports.getTimeZone=s,exports.getTranslations=g,exports.unstable_setRequestLocale=a;
|
|
@@ -8,7 +8,6 @@ export declare function formatTemplatePathname(sourcePathname: string, sourceTem
|
|
|
8
8
|
*/
|
|
9
9
|
export declare function getNormalizedPathname<Locales extends AllLocales>(pathname: string, locales: Locales): string;
|
|
10
10
|
export declare function getKnownLocaleFromPathname<Locales extends AllLocales>(pathname: string, locales: Locales): Locales[number] | undefined;
|
|
11
|
-
export declare function getBasePath(pathname: string, pathLocale: string): string;
|
|
12
11
|
export declare function getRouteParams(template: string, pathname: string): Record<string, string> | undefined;
|
|
13
12
|
export declare function formatPathname(template: string, params?: object): string;
|
|
14
13
|
export declare function getPathWithSearch(pathname: string, search: string | undefined): string;
|
|
@@ -1,58 +1,9 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { getRequestConfig as getRequestConfig_type, getFormatter as getFormatter_type, getNow as getNow_type, getTimeZone as getTimeZone_type, getMessages as getMessages_type, getLocale as getLocale_type, unstable_setRequestLocale as unstable_setRequestLocale_type } from '../react-server';
|
|
3
2
|
export declare function getRequestConfig(...args: Parameters<typeof getRequestConfig_type>): ReturnType<typeof getRequestConfig_type>;
|
|
4
3
|
export declare const getFormatter: typeof getFormatter_type;
|
|
5
4
|
export declare const getNow: typeof getNow_type;
|
|
6
5
|
export declare const getTimeZone: typeof getTimeZone_type;
|
|
7
|
-
export declare const getTranslations: {
|
|
8
|
-
<NestedKey extends string = never>(namespace?: NestedKey | undefined): Promise<{
|
|
9
|
-
<TargetKey extends import("use-intl/dist/types/src/core/utils/MessageKeys").default<import("use-intl/dist/types/src/core/utils/NestedValueOf").default<{
|
|
10
|
-
'!': IntlMessages;
|
|
11
|
-
}, [NestedKey] extends [never] ? "!" : `!.${NestedKey}`>, import("use-intl/dist/types/src/core/utils/NestedKeyOf").default<import("use-intl/dist/types/src/core/utils/NestedValueOf").default<{
|
|
12
|
-
'!': IntlMessages;
|
|
13
|
-
}, [NestedKey] extends [never] ? "!" : `!.${NestedKey}`>>>>(key: [TargetKey] extends [never] ? string : TargetKey, values?: import("use-intl/dist/types/src/core/TranslationValues").default | undefined, formats?: Partial<import("use-intl/dist/types/src/core/Formats").default> | undefined): string;
|
|
14
|
-
rich<TargetKey_1 extends import("use-intl/dist/types/src/core/utils/MessageKeys").default<import("use-intl/dist/types/src/core/utils/NestedValueOf").default<{
|
|
15
|
-
'!': IntlMessages;
|
|
16
|
-
}, [NestedKey] extends [never] ? "!" : `!.${NestedKey}`>, import("use-intl/dist/types/src/core/utils/NestedKeyOf").default<import("use-intl/dist/types/src/core/utils/NestedValueOf").default<{
|
|
17
|
-
'!': IntlMessages;
|
|
18
|
-
}, [NestedKey] extends [never] ? "!" : `!.${NestedKey}`>>>>(key: [TargetKey_1] extends [never] ? string : TargetKey_1, values?: import("use-intl").RichTranslationValues | undefined, formats?: Partial<import("use-intl/dist/types/src/core/Formats").default> | undefined): string | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNodeArray;
|
|
19
|
-
markup<TargetKey_2 extends import("use-intl/dist/types/src/core/utils/MessageKeys").default<import("use-intl/dist/types/src/core/utils/NestedValueOf").default<{
|
|
20
|
-
'!': IntlMessages;
|
|
21
|
-
}, [NestedKey] extends [never] ? "!" : `!.${NestedKey}`>, import("use-intl/dist/types/src/core/utils/NestedKeyOf").default<import("use-intl/dist/types/src/core/utils/NestedValueOf").default<{
|
|
22
|
-
'!': IntlMessages;
|
|
23
|
-
}, [NestedKey] extends [never] ? "!" : `!.${NestedKey}`>>>>(key: [TargetKey_2] extends [never] ? string : TargetKey_2, values?: import("use-intl").MarkupTranslationValues | undefined, formats?: Partial<import("use-intl/dist/types/src/core/Formats").default> | undefined): string;
|
|
24
|
-
raw<TargetKey_3 extends import("use-intl/dist/types/src/core/utils/MessageKeys").default<import("use-intl/dist/types/src/core/utils/NestedValueOf").default<{
|
|
25
|
-
'!': IntlMessages;
|
|
26
|
-
}, [NestedKey] extends [never] ? "!" : `!.${NestedKey}`>, import("use-intl/dist/types/src/core/utils/NestedKeyOf").default<import("use-intl/dist/types/src/core/utils/NestedValueOf").default<{
|
|
27
|
-
'!': IntlMessages;
|
|
28
|
-
}, [NestedKey] extends [never] ? "!" : `!.${NestedKey}`>>>>(key: [TargetKey_3] extends [never] ? string : TargetKey_3): any;
|
|
29
|
-
}>;
|
|
30
|
-
<NestedKey_1 extends string = never>(opts?: {
|
|
31
|
-
locale: string;
|
|
32
|
-
namespace?: NestedKey_1 | undefined;
|
|
33
|
-
} | undefined): Promise<{
|
|
34
|
-
<TargetKey_4 extends import("use-intl/dist/types/src/core/utils/MessageKeys").default<import("use-intl/dist/types/src/core/utils/NestedValueOf").default<{
|
|
35
|
-
'!': IntlMessages;
|
|
36
|
-
}, [NestedKey_1] extends [never] ? "!" : `!.${NestedKey_1}`>, import("use-intl/dist/types/src/core/utils/NestedKeyOf").default<import("use-intl/dist/types/src/core/utils/NestedValueOf").default<{
|
|
37
|
-
'!': IntlMessages;
|
|
38
|
-
}, [NestedKey_1] extends [never] ? "!" : `!.${NestedKey_1}`>>>>(key: TargetKey_4, values?: import("use-intl/dist/types/src/core/TranslationValues").default | undefined, formats?: Partial<import("use-intl/dist/types/src/core/Formats").default> | undefined): string;
|
|
39
|
-
rich<TargetKey_5 extends import("use-intl/dist/types/src/core/utils/MessageKeys").default<import("use-intl/dist/types/src/core/utils/NestedValueOf").default<{
|
|
40
|
-
'!': IntlMessages;
|
|
41
|
-
}, [NestedKey_1] extends [never] ? "!" : `!.${NestedKey_1}`>, import("use-intl/dist/types/src/core/utils/NestedKeyOf").default<import("use-intl/dist/types/src/core/utils/NestedValueOf").default<{
|
|
42
|
-
'!': IntlMessages;
|
|
43
|
-
}, [NestedKey_1] extends [never] ? "!" : `!.${NestedKey_1}`>>>>(key: TargetKey_5, values?: import("use-intl").RichTranslationValues | undefined, formats?: Partial<import("use-intl/dist/types/src/core/Formats").default> | undefined): string | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactNodeArray;
|
|
44
|
-
markup<TargetKey_6 extends import("use-intl/dist/types/src/core/utils/MessageKeys").default<import("use-intl/dist/types/src/core/utils/NestedValueOf").default<{
|
|
45
|
-
'!': IntlMessages;
|
|
46
|
-
}, [NestedKey_1] extends [never] ? "!" : `!.${NestedKey_1}`>, import("use-intl/dist/types/src/core/utils/NestedKeyOf").default<import("use-intl/dist/types/src/core/utils/NestedValueOf").default<{
|
|
47
|
-
'!': IntlMessages;
|
|
48
|
-
}, [NestedKey_1] extends [never] ? "!" : `!.${NestedKey_1}`>>>>(key: TargetKey_6, values?: import("use-intl").MarkupTranslationValues | undefined, formats?: Partial<import("use-intl/dist/types/src/core/Formats").default> | undefined): string;
|
|
49
|
-
raw<TargetKey_7 extends import("use-intl/dist/types/src/core/utils/MessageKeys").default<import("use-intl/dist/types/src/core/utils/NestedValueOf").default<{
|
|
50
|
-
'!': IntlMessages;
|
|
51
|
-
}, [NestedKey_1] extends [never] ? "!" : `!.${NestedKey_1}`>, import("use-intl/dist/types/src/core/utils/NestedKeyOf").default<import("use-intl/dist/types/src/core/utils/NestedValueOf").default<{
|
|
52
|
-
'!': IntlMessages;
|
|
53
|
-
}, [NestedKey_1] extends [never] ? "!" : `!.${NestedKey_1}`>>>>(key: TargetKey_7): any;
|
|
54
|
-
}>;
|
|
55
|
-
};
|
|
56
6
|
export declare const getMessages: typeof getMessages_type;
|
|
57
7
|
export declare const getLocale: typeof getLocale_type;
|
|
8
|
+
export declare const getTranslations: () => never;
|
|
58
9
|
export declare const unstable_setRequestLocale: typeof unstable_setRequestLocale_type;
|
|
@@ -1,23 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
getMessageFallback?: ((info: {
|
|
8
|
-
error: import("use-intl/core").IntlError;
|
|
9
|
-
key: string;
|
|
10
|
-
namespace?: string | undefined;
|
|
11
|
-
}) => string) | undefined;
|
|
12
|
-
messages?: import("use-intl/dist/types/src/core/AbstractIntlMessages").default | undefined;
|
|
13
|
-
defaultTranslationValues?: import("use-intl/core").RichTranslationValues | undefined;
|
|
14
|
-
}, "onError" | "getMessageFallback" | "messages"> & {
|
|
15
|
-
messages: import("use-intl/dist/types/src/core/AbstractIntlMessages").default | undefined;
|
|
16
|
-
onError: typeof import("use-intl/dist/types/src/core/defaults").defaultOnError;
|
|
17
|
-
getMessageFallback: (info: {
|
|
18
|
-
error: import("use-intl/core").IntlError;
|
|
19
|
-
key: string;
|
|
20
|
-
namespace?: string | undefined;
|
|
21
|
-
}) => string;
|
|
1
|
+
import { IntlConfig } from 'use-intl/core';
|
|
2
|
+
declare const getConfig: (locale: string) => Promise<IntlConfig & {
|
|
3
|
+
getMessageFallback: NonNullable<IntlConfig['getMessageFallback']>;
|
|
4
|
+
now: NonNullable<IntlConfig['now']>;
|
|
5
|
+
onError: NonNullable<IntlConfig['onError']>;
|
|
6
|
+
timeZone: NonNullable<IntlConfig['timeZone']>;
|
|
22
7
|
}>;
|
|
23
8
|
export default getConfig;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createFormatter } from 'use-intl/core';
|
|
1
2
|
/**
|
|
2
3
|
* Returns a formatter based on the given locale.
|
|
3
4
|
*
|
|
@@ -6,9 +7,4 @@
|
|
|
6
7
|
*/
|
|
7
8
|
export default function getFormatter(opts?: {
|
|
8
9
|
locale?: string;
|
|
9
|
-
}): Promise<
|
|
10
|
-
dateTime: (value: number | Date, formatOrOptions?: string | import("use-intl/dist/types/src/core/DateTimeFormatOptions").default | undefined) => string;
|
|
11
|
-
number: (value: number | bigint, formatOrOptions?: string | import("use-intl/core").NumberFormatOptions | undefined) => string;
|
|
12
|
-
relativeTime: (date: number | Date, nowOrOptions?: number | Date | import("use-intl/dist/types/src/core/RelativeTimeFormatOptions").default | undefined) => string;
|
|
13
|
-
list: (value: Iterable<string>, formatOrOptions?: string | Intl.ListFormatOptions | undefined) => string;
|
|
14
|
-
}>;
|
|
10
|
+
}): Promise<ReturnType<typeof createFormatter>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.5",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@formatjs/intl-localematcher": "^0.2.32",
|
|
82
82
|
"negotiator": "^0.6.3",
|
|
83
|
-
"use-intl": "^3.2.
|
|
83
|
+
"use-intl": "^3.2.5"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
|
|
@@ -137,5 +137,5 @@
|
|
|
137
137
|
"limit": "5.72 KB"
|
|
138
138
|
}
|
|
139
139
|
],
|
|
140
|
-
"gitHead": "
|
|
140
|
+
"gitHead": "bbeec3b77313eba54b526a0e6452a2331f6aae06"
|
|
141
141
|
}
|