use-intl 3.26.0 → 3.26.1

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 CHANGED
@@ -80,4 +80,4 @@ function App({user}) {
80
80
 
81
81
  Have a look at [the minimal setup example](https://github.com/amannn/next-intl/tree/main/examples/example-use-intl) to explore a working app.
82
82
 
83
- ### [→ Read the docs](https://next-intl-docs.vercel.app/docs/environments/core-library)
83
+ ### [→ Read the docs](https://next-intl.dev/docs/environments/core-library)
@@ -6,7 +6,7 @@ var IntlContext = require('./IntlContext-BKfsnzBx.js');
6
6
  function useIntlContext() {
7
7
  const context = React.useContext(IntlContext.IntlContext);
8
8
  if (!context) {
9
- throw new Error('No intl context found. Have you configured the provider? See https://next-intl-docs.vercel.app/docs/usage/configuration#client-server-components' );
9
+ throw new Error('No intl context found. Have you configured the provider? See https://next-intl.dev/docs/usage/configuration#client-server-components' );
10
10
  }
11
11
  return context;
12
12
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var _useLocale = require('./_useLocale-0Rl9uR82.js');
5
+ var _useLocale = require('./_useLocale-BK3jOeaA.js');
6
6
  require('react');
7
7
  require('./IntlContext-BKfsnzBx.js');
8
8
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var initializeConfig = require('./initializeConfig-BhfMSHP7.js');
6
- var createFormatter = require('./createFormatter-D2v4ATzl.js');
6
+ var createFormatter = require('./createFormatter-QqAaZwGD.js');
7
7
  require('@formatjs/fast-memoize');
8
8
  require('intl-messageformat');
9
9
  require('react');
@@ -188,12 +188,12 @@ function createBaseTranslatorImpl(_ref) {
188
188
  if (Array.isArray(message)) {
189
189
  code = initializeConfig.IntlErrorCode.INVALID_MESSAGE;
190
190
  {
191
- errorMessage = "Message at `".concat(initializeConfig.joinPath(namespace, key), "` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages");
191
+ errorMessage = "Message at `".concat(initializeConfig.joinPath(namespace, key), "` resolved to an array, but only strings are supported. See https://next-intl.dev/docs/usage/messages#arrays-of-messages");
192
192
  }
193
193
  } else {
194
194
  code = initializeConfig.IntlErrorCode.INSUFFICIENT_PATH;
195
195
  {
196
- errorMessage = "Message at `".concat(initializeConfig.joinPath(namespace, key), "` resolved to an object, but only strings are supported. Use a `.` to retrieve nested messages. See https://next-intl-docs.vercel.app/docs/usage/messages#structuring-messages");
196
+ errorMessage = "Message at `".concat(initializeConfig.joinPath(namespace, key), "` resolved to an object, but only strings are supported. Use a `.` to retrieve nested messages. See https://next-intl.dev/docs/usage/messages#structuring-messages");
197
197
  }
198
198
  }
199
199
  return getFallbackFromErrorAndNotify(key, code, errorMessage);
@@ -390,7 +390,7 @@ function createFormatter(_ref) {
390
390
  timeZone: globalTimeZone
391
391
  };
392
392
  } else {
393
- onError(new initializeConfig.IntlError(initializeConfig.IntlErrorCode.ENVIRONMENT_FALLBACK, "The `timeZone` parameter wasn't provided and there is no global default configured. Consider adding a global default to avoid markup mismatches caused by environment differences. Learn more: https://next-intl-docs.vercel.app/docs/configuration#time-zone" ));
393
+ onError(new initializeConfig.IntlError(initializeConfig.IntlErrorCode.ENVIRONMENT_FALLBACK, "The `timeZone` parameter wasn't provided and there is no global default configured. Consider adding a global default to avoid markup mismatches caused by environment differences. Learn more: https://next-intl.dev/docs/configuration#time-zone" ));
394
394
  }
395
395
  }
396
396
  return options;
@@ -452,7 +452,7 @@ function createFormatter(_ref) {
452
452
  if (globalNow) {
453
453
  return globalNow;
454
454
  } else {
455
- onError(new initializeConfig.IntlError(initializeConfig.IntlErrorCode.ENVIRONMENT_FALLBACK, "The `now` parameter wasn't provided and there is no global default configured. Consider adding a global default to avoid markup mismatches caused by environment differences. Learn more: https://next-intl-docs.vercel.app/docs/configuration#now" ));
455
+ onError(new initializeConfig.IntlError(initializeConfig.IntlErrorCode.ENVIRONMENT_FALLBACK, "The `now` parameter wasn't provided and there is no global default configured. Consider adding a global default to avoid markup mismatches caused by environment differences. Learn more: https://next-intl.dev/docs/configuration#now" ));
456
456
  return new Date();
457
457
  }
458
458
  }
@@ -4,10 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var initializeConfig = require('./initializeConfig-BhfMSHP7.js');
6
6
  var core = require('./core.js');
7
- var createFormatter = require('./createFormatter-D2v4ATzl.js');
7
+ var createFormatter = require('./createFormatter-QqAaZwGD.js');
8
8
  var _IntlProvider = require('./_IntlProvider.js');
9
9
  var react = require('./react.js');
10
- var _useLocale = require('./_useLocale-0Rl9uR82.js');
10
+ var _useLocale = require('./_useLocale-BK3jOeaA.js');
11
11
  require('@formatjs/fast-memoize');
12
12
  require('intl-messageformat');
13
13
  require('react');
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _IntlProvider = require('./_IntlProvider.js');
6
- var _useLocale = require('./_useLocale-0Rl9uR82.js');
6
+ var _useLocale = require('./_useLocale-BK3jOeaA.js');
7
7
  var React = require('react');
8
- var createFormatter = require('./createFormatter-D2v4ATzl.js');
8
+ var createFormatter = require('./createFormatter-QqAaZwGD.js');
9
9
  var initializeConfig = require('./initializeConfig-BhfMSHP7.js');
10
10
  require('./IntlContext-BKfsnzBx.js');
11
11
  require('intl-messageformat');
@@ -32,7 +32,7 @@ function useTranslationsImpl(allMessagesPrefixed, namespacePrefixed, namespacePr
32
32
  if (!timeZone && !hasWarnedForMissingTimezone && isServer) {
33
33
  // eslint-disable-next-line react-compiler/react-compiler
34
34
  hasWarnedForMissingTimezone = true;
35
- onError(new initializeConfig.IntlError(initializeConfig.IntlErrorCode.ENVIRONMENT_FALLBACK, "There is no `timeZone` configured, this can lead to markup mismatches caused by environment differences. Consider adding a global default: https://next-intl-docs.vercel.app/docs/configuration#time-zone" ));
35
+ onError(new initializeConfig.IntlError(initializeConfig.IntlErrorCode.ENVIRONMENT_FALLBACK, "There is no `timeZone` configured, this can lead to markup mismatches caused by environment differences. Consider adding a global default: https://next-intl.dev/docs/configuration#time-zone" ));
36
36
  }
37
37
  const translate = React.useMemo(() => createFormatter.createBaseTranslator({
38
38
  cache,
@@ -118,7 +118,7 @@ function useTimeZone() {
118
118
  function useMessages() {
119
119
  const context = _useLocale.useIntlContext();
120
120
  if (!context.messages) {
121
- throw new Error('No messages found. Have you configured them correctly? See https://next-intl-docs.vercel.app/docs/configuration#messages' );
121
+ throw new Error('No messages found. Have you configured them correctly? See https://next-intl.dev/docs/configuration#messages' );
122
122
  }
123
123
  return context.messages;
124
124
  }
@@ -0,0 +1 @@
1
+ import{useContext as t}from"react";import{I as o}from"./IntlContext-DoS4CDM3.js";function e(){const e=t(o);if(!e)throw new Error("No intl context found. Have you configured the provider? See https://next-intl.dev/docs/usage/configuration#client-server-components");return e}function n(){return e().locale}export{e as a,n as u};
@@ -1 +1 @@
1
- export{u as useLocale}from"./_useLocale-v-ZT5JoE.js";import"react";import"./IntlContext-DoS4CDM3.js";
1
+ export{u as useLocale}from"./_useLocale-7W3qm3h_.js";import"react";import"./IntlContext-DoS4CDM3.js";
package/dist/esm/core.js CHANGED
@@ -1 +1 @@
1
- import{b as e,c as r,e as t,d as s}from"./initializeConfig-D2A8plWf.js";export{I as IntlError,a as IntlErrorCode,i as initializeConfig}from"./initializeConfig-D2A8plWf.js";import{r as o,a as m}from"./createFormatter-zqPbsiYR.js";export{c as createFormatter}from"./createFormatter-zqPbsiYR.js";import"@formatjs/fast-memoize";import"intl-messageformat";import"react";function n(a){let{_cache:i=e(),_formatters:c=r(i),getMessageFallback:n=t,messages:f,namespace:l,onError:g=s,...p}=a;return function(e,a){let{messages:r,namespace:t,...s}=e;return r=r[a],t=o(t,a),m({...s,messages:r,namespace:t})}({...p,onError:g,cache:i,formatters:c,getMessageFallback:n,messages:{"!":f},namespace:l?"!.".concat(l):"!"},"!")}export{e as _createCache,r as _createIntlFormatters,n as createTranslator};
1
+ import{b as e,c as r,e as t,d as s}from"./initializeConfig-D2A8plWf.js";export{I as IntlError,a as IntlErrorCode,i as initializeConfig}from"./initializeConfig-D2A8plWf.js";import{r as o,a as m}from"./createFormatter-D4OO35MB.js";export{c as createFormatter}from"./createFormatter-D4OO35MB.js";import"@formatjs/fast-memoize";import"intl-messageformat";import"react";function n(a){let{_cache:i=e(),_formatters:c=r(i),getMessageFallback:n=t,messages:f,namespace:l,onError:g=s,...p}=a;return function(e,a){let{messages:r,namespace:t,...s}=e;return r=r[a],t=o(t,a),m({...s,messages:r,namespace:t})}({...p,onError:g,cache:i,formatters:c,getMessageFallback:n,messages:{"!":f},namespace:l?"!.".concat(l):"!"},"!")}export{e as _createCache,r as _createIntlFormatters,n as createTranslator};
@@ -0,0 +1 @@
1
+ import e from"intl-messageformat";import{isValidElement as t,cloneElement as n}from"react";import{I as r,a as o,j as a,d as s,e as i,m as c,b as u,c as m}from"./initializeConfig-D2A8plWf.js";function l(e,t){return e?Object.keys(e).reduce(((n,r)=>(n[r]={timeZone:t,...e[r]},n)),{}):e}function f(e,t,n,r){const o=a(r,n);if(!t)throw new Error("No messages available at `".concat(r,"`."));let s=t;return n.split(".").forEach((t=>{const n=s[t];if(null==t||null==n)throw new Error("Could not resolve `".concat(o,"` in messages for locale `").concat(e,"`."));s=n})),s}function g(u){const m=function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s;try{if(!t)throw new Error("No messages were configured on the provider.");const r=n?f(e,t,n):t;if(!r)throw new Error("No messages for namespace `".concat(n,"` found."));return r}catch(e){const t=new r(o.MISSING_MESSAGE,e.message);return a(t),t}}(u.locale,u.messages,u.namespace,u.onError);return function(s){let{cache:u,defaultTranslationValues:m,formats:g,formatters:d,getMessageFallback:h=i,locale:p,messagesOrError:y,namespace:v,onError:w,timeZone:E}=s;const T=y instanceof r;function S(e,t,n){const o=new r(t,n);return w(o),h({error:o,key:e,namespace:v})}function b(r,s,i){if(T)return h({error:y,key:r,namespace:v});const w=y;let b,M;try{b=f(p,w,r,v)}catch(e){return S(r,o.MISSING_MESSAGE,e.message)}if("object"==typeof b){let e,t;return Array.isArray(b)?(e=o.INVALID_MESSAGE,t="Message at `".concat(a(v,r),"` resolved to an array, but only strings are supported. See https://next-intl.dev/docs/usage/messages#arrays-of-messages")):(e=o.INSUFFICIENT_PATH,t="Message at `".concat(a(v,r),"` resolved to an object, but only strings are supported. Use a `.` to retrieve nested messages. See https://next-intl.dev/docs/usage/messages#structuring-messages")),S(r,e,t)}const I=function(e,t){if(t)return;const n=e.replace(/'([{}])/gi,"$1");return/<|{/.test(n)?void 0:n}(b,s);if(I)return I;d.getMessageFormat||(d.getMessageFormat=function(t,n){const r=c((function(){return new e(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],{formatters:n,...arguments.length<=3?void 0:arguments[3]})}),t.message);return r}(u,d));try{M=d.getMessageFormat(b,p,function(t,n){const r=n?{...t,dateTime:l(t.dateTime,n)}:t,o=e.formats.date,a=n?l(o,n):o,s=e.formats.time,i=n?l(s,n):s;return{...r,date:{...a,...r.dateTime},time:{...i,...r.dateTime}}}({...g,...i},E),{formatters:{...d,getDateTimeFormat:(e,t)=>d.getDateTimeFormat(e,{timeZone:E,...t})}})}catch(e){const t=e;return S(r,o.INVALID_MESSAGE,t.message+("originalMessage"in t?" (".concat(t.originalMessage,")"):""))}try{const e=M.format(function(e){if(0===Object.keys(e).length)return;const r={};return Object.keys(e).forEach((o=>{let a=0;const s=e[o];let i;i="function"==typeof s?e=>{const r=s(e);return t(r)?n(r,{key:o+a++}):r}:s,r[o]=i})),r}({...m,...s}));if(null==e)throw new Error("Unable to format `".concat(r,"` in ").concat(v?"namespace `".concat(v,"`"):"messages"));return t(e)||Array.isArray(e)||"string"==typeof e?e:String(e)}catch(e){return S(r,o.FORMATTING_ERROR,e.message)}}function M(e,t,n){const r=b(e,t,n);return"string"!=typeof r?S(e,o.INVALID_MESSAGE,"The message `".concat(e,"` in ").concat(v?"namespace `".concat(v,"`"):"messages"," didn't resolve to a string. If you want to format rich text, use `t.rich` instead.")):r}return M.rich=b,M.markup=(e,t,n)=>{const a=b(e,t,n);if("string"!=typeof a){const t=new r(o.FORMATTING_ERROR,"`t.markup` only accepts functions for formatting that receive and return strings.\n\nE.g. t.markup('markup', {b: (chunks) => `<b>${chunks}</b>`})");return w(t),h({error:t,key:e,namespace:v})}return a},M.raw=e=>{if(T)return h({error:y,key:e,namespace:v});const t=y;try{return f(p,t,e,v)}catch(t){return S(e,o.MISSING_MESSAGE,t.message)}},M.has=e=>{if(T)return!1;try{return f(p,y,e,v),!0}catch(e){return!1}},M}({...u,messagesOrError:m})}function d(e,t){return e===t?void 0:e.slice((t+".").length)}const h=60,p=60*h,y=24*p,v=7*y,w=y*(365/12),E=3*w,T=365*y,S={second:1,seconds:1,minute:h,minutes:h,hour:p,hours:p,day:y,days:y,week:v,weeks:v,month:w,months:w,quarter:E,quarters:E,year:T,years:T};function b(e){let{_cache:t=u(),_formatters:n=m(t),formats:a,locale:i,now:c,onError:l=s,timeZone:f}=e;function g(e){var t;return null!==(t=e)&&void 0!==t&&t.timeZone||(f?e={...e,timeZone:f}:l(new r(o.ENVIRONMENT_FALLBACK,"The `timeZone` parameter wasn't provided and there is no global default configured. Consider adding a global default to avoid markup mismatches caused by environment differences. Learn more: https://next-intl.dev/docs/configuration#time-zone"))),e}function d(e,t,n,a){let s;try{s=function(e,t){let n;if("string"==typeof t){const a=t;if(n=null==e?void 0:e[a],!n){const e=new r(o.MISSING_FORMAT,"Format `".concat(a,"` is not available. You can configure it on the provider or provide custom options."));throw l(e),e}}else n=t;return n}(t,e)}catch(e){return a()}try{return n(s)}catch(e){return l(new r(o.FORMATTING_ERROR,e.message)),a()}}function E(e,t){return d(t,null==a?void 0:a.dateTime,(t=>(t=g(t),n.getDateTimeFormat(i,t).format(e))),(()=>String(e)))}function b(){return c||(l(new r(o.ENVIRONMENT_FALLBACK,"The `now` parameter wasn't provided and there is no global default configured. Consider adding a global default to avoid markup mismatches caused by environment differences. Learn more: https://next-intl.dev/docs/configuration#now")),new Date)}return{dateTime:E,number:function(e,t){return d(t,null==a?void 0:a.number,(t=>n.getNumberFormat(i,t).format(e)),(()=>String(e)))},relativeTime:function(e,t){try{let r,o;const a={};t instanceof Date||"number"==typeof t?r=new Date(t):t&&(r=null!=t.now?new Date(t.now):b(),o=t.unit,a.style=t.style,a.numberingSystem=t.numberingSystem),r||(r=b());const s=(new Date(e).getTime()-r.getTime())/1e3;o||(o=function(e){const t=Math.abs(e);return t<h?"second":t<p?"minute":t<y?"hour":t<v?"day":t<w?"week":t<T?"month":"year"}(s)),a.numeric="second"===o?"auto":"always";const c=function(e,t){return Math.round(e/S[t])}(s,o);return n.getRelativeTimeFormat(i,a).format(c,o)}catch(t){return l(new r(o.FORMATTING_ERROR,t.message)),String(e)}},list:function(e,t){const r=[],o=new Map;let s=0;for(const t of e){let e;"object"==typeof t?(e=String(s),o.set(e,t)):e=String(t),r.push(e),s++}return d(t,null==a?void 0:a.list,(e=>{const t=n.getListFormat(i,e).formatToParts(r).map((e=>"literal"===e.type?e.value:o.get(e.value)||e.value));return o.size>0?t:t.join("")}),(()=>String(e)))},dateTimeRange:function(e,t,r){return d(r,null==a?void 0:a.dateTime,(r=>(r=g(r),n.getDateTimeFormat(i,r).formatRange(e,t))),(()=>[E(e),E(t)].join(" – ")))}}}export{g as a,b as c,d as r};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- export{I as IntlError,a as IntlErrorCode,b as _createCache,c as _createIntlFormatters,i as initializeConfig}from"./initializeConfig-D2A8plWf.js";export{createTranslator}from"./core.js";export{c as createFormatter}from"./createFormatter-zqPbsiYR.js";export{IntlProvider}from"./_IntlProvider.js";export{useFormatter,useMessages,useNow,useTimeZone,useTranslations}from"./react.js";export{u as useLocale}from"./_useLocale-v-ZT5JoE.js";import"@formatjs/fast-memoize";import"intl-messageformat";import"react";import"./IntlContext-DoS4CDM3.js";
1
+ export{I as IntlError,a as IntlErrorCode,b as _createCache,c as _createIntlFormatters,i as initializeConfig}from"./initializeConfig-D2A8plWf.js";export{createTranslator}from"./core.js";export{c as createFormatter}from"./createFormatter-D4OO35MB.js";export{IntlProvider}from"./_IntlProvider.js";export{useFormatter,useMessages,useNow,useTimeZone,useTranslations}from"./react.js";export{u as useLocale}from"./_useLocale-7W3qm3h_.js";import"@formatjs/fast-memoize";import"intl-messageformat";import"react";import"./IntlContext-DoS4CDM3.js";
package/dist/esm/react.js CHANGED
@@ -1 +1 @@
1
- export{IntlProvider}from"./_IntlProvider.js";import{a as e}from"./_useLocale-v-ZT5JoE.js";export{u as useLocale}from"./_useLocale-v-ZT5JoE.js";import{useMemo as t,useState as o,useEffect as r}from"react";import{r as n,a,c as s}from"./createFormatter-zqPbsiYR.js";import{I as i,a as c}from"./initializeConfig-D2A8plWf.js";import"./IntlContext-DoS4CDM3.js";import"intl-messageformat";import"@formatjs/fast-memoize";let m=!1;const l="undefined"==typeof window;function f(o){return function(o,r,s){const{cache:f,defaultTranslationValues:u,formats:d,formatters:p,getMessageFallback:g,locale:v,onError:h,timeZone:w}=e(),I=o[s],j=n(r,s);return w||m||!l||(m=!0,h(new i(c.ENVIRONMENT_FALLBACK,"There is no `timeZone` configured, this can lead to markup mismatches caused by environment differences. Consider adding a global default: https://next-intl-docs.vercel.app/docs/configuration#time-zone"))),t((()=>a({cache:f,formatters:p,getMessageFallback:g,messages:I,defaultTranslationValues:u,namespace:j,onError:h,formats:d,locale:v,timeZone:w})),[f,p,g,I,u,j,h,d,v,w])}({"!":e().messages},o?"!.".concat(o):"!","!")}function d(){return new Date}function p(t){const n=null==t?void 0:t.updateInterval,{now:a}=e(),[s,i]=o(a||d());return r((()=>{if(!n)return;const e=setInterval((()=>{i(d())}),n);return()=>{clearInterval(e)}}),[a,n]),null==n&&a?a:s}function g(){return e().timeZone}function v(){const t=e();if(!t.messages)throw new Error("No messages found. Have you configured them correctly? See https://next-intl-docs.vercel.app/docs/configuration#messages");return t.messages}function h(){const{formats:o,formatters:r,locale:n,now:a,onError:i,timeZone:c}=e();return t((()=>s({formats:o,locale:n,now:a,onError:i,timeZone:c,_formatters:r})),[o,r,a,n,i,c])}export{h as useFormatter,v as useMessages,p as useNow,g as useTimeZone,f as useTranslations};
1
+ export{IntlProvider}from"./_IntlProvider.js";import{a as e}from"./_useLocale-7W3qm3h_.js";export{u as useLocale}from"./_useLocale-7W3qm3h_.js";import{useMemo as t,useState as o,useEffect as r}from"react";import{r as n,a,c as s}from"./createFormatter-D4OO35MB.js";import{I as i,a as m}from"./initializeConfig-D2A8plWf.js";import"./IntlContext-DoS4CDM3.js";import"intl-messageformat";import"@formatjs/fast-memoize";let c=!1;const l="undefined"==typeof window;function f(o){return function(o,r,s){const{cache:f,defaultTranslationValues:u,formats:d,formatters:g,getMessageFallback:p,locale:v,onError:h,timeZone:w}=e(),I=o[s],j=n(r,s);return w||c||!l||(c=!0,h(new i(m.ENVIRONMENT_FALLBACK,"There is no `timeZone` configured, this can lead to markup mismatches caused by environment differences. Consider adding a global default: https://next-intl.dev/docs/configuration#time-zone"))),t((()=>a({cache:f,formatters:g,getMessageFallback:p,messages:I,defaultTranslationValues:u,namespace:j,onError:h,formats:d,locale:v,timeZone:w})),[f,g,p,I,u,j,h,d,v,w])}({"!":e().messages},o?"!.".concat(o):"!","!")}function d(){return new Date}function g(t){const n=null==t?void 0:t.updateInterval,{now:a}=e(),[s,i]=o(a||d());return r((()=>{if(!n)return;const e=setInterval((()=>{i(d())}),n);return()=>{clearInterval(e)}}),[a,n]),null==n&&a?a:s}function p(){return e().timeZone}function v(){const t=e();if(!t.messages)throw new Error("No messages found. Have you configured them correctly? See https://next-intl.dev/docs/configuration#messages");return t.messages}function h(){const{formats:o,formatters:r,locale:n,now:a,onError:i,timeZone:m}=e();return t((()=>s({formats:o,locale:n,now:a,onError:i,timeZone:m,_formatters:r})),[o,r,a,n,i,m])}export{h as useFormatter,v as useMessages,g as useNow,p as useTimeZone,f as useTranslations};
@@ -1,7 +1,7 @@
1
1
  /** A generic type that describes the shape of messages.
2
2
  *
3
3
  * Optionally `IntlMessages` can be provided to get type safety for message
4
- * namespaces and keys. See https://next-intl-docs.vercel.app/docs/usage/typescript
4
+ * namespaces and keys. See https://next-intl.dev/docs/usage/typescript
5
5
  */
6
6
  type AbstractIntlMessages = {
7
7
  [id: string]: AbstractIntlMessages | string;
@@ -43,7 +43,7 @@ type IntlConfig<Messages = AbstractIntlMessages> = {
43
43
  * Can be used for consistent usage or styling of rich text elements.
44
44
  * Defaults will be overidden by locally provided values.
45
45
  *
46
- * @deprecated See https://next-intl-docs.vercel.app/docs/usage/messages#rich-text-reuse-tags
46
+ * @deprecated See https://next-intl.dev/docs/usage/messages#rich-text-reuse-tags
47
47
  **/
48
48
  defaultTranslationValues?: RichTranslationValues;
49
49
  };
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "use-intl",
3
- "version": "3.26.0",
3
+ "version": "3.26.1",
4
4
  "sideEffects": false,
5
5
  "author": "Jan Amann <jan@amann.work>",
6
6
  "description": "Internationalization (i18n) for React",
7
7
  "license": "MIT",
8
- "homepage": "https://next-intl-docs.vercel.app/",
8
+ "homepage": "https://next-intl.dev",
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "https://github.com/amannn/next-intl/tree/main/packages/use-intl"
@@ -70,5 +70,5 @@
70
70
  "peerDependencies": {
71
71
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0 || ^19.0.0"
72
72
  },
73
- "gitHead": "a08bf13e51994775a4ed728b93e8131e42d6218b"
73
+ "gitHead": "33cae85fcf6421f076358f9db26b5e137e83e543"
74
74
  }
@@ -1 +0,0 @@
1
- import{useContext as o}from"react";import{I as t}from"./IntlContext-DoS4CDM3.js";function e(){const e=o(t);if(!e)throw new Error("No intl context found. Have you configured the provider? See https://next-intl-docs.vercel.app/docs/usage/configuration#client-server-components");return e}function n(){return e().locale}export{e as a,n as u};
@@ -1 +0,0 @@
1
- import e from"intl-messageformat";import{isValidElement as t,cloneElement as n}from"react";import{I as r,a as o,j as a,d as s,e as i,m as c,b as u,c as m}from"./initializeConfig-D2A8plWf.js";function l(e,t){return e?Object.keys(e).reduce(((n,r)=>(n[r]={timeZone:t,...e[r]},n)),{}):e}function f(e,t,n,r){const o=a(r,n);if(!t)throw new Error("No messages available at `".concat(r,"`."));let s=t;return n.split(".").forEach((t=>{const n=s[t];if(null==t||null==n)throw new Error("Could not resolve `".concat(o,"` in messages for locale `").concat(e,"`."));s=n})),s}function g(u){const m=function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s;try{if(!t)throw new Error("No messages were configured on the provider.");const r=n?f(e,t,n):t;if(!r)throw new Error("No messages for namespace `".concat(n,"` found."));return r}catch(e){const t=new r(o.MISSING_MESSAGE,e.message);return a(t),t}}(u.locale,u.messages,u.namespace,u.onError);return function(s){let{cache:u,defaultTranslationValues:m,formats:g,formatters:d,getMessageFallback:p=i,locale:h,messagesOrError:y,namespace:v,onError:w,timeZone:E}=s;const T=y instanceof r;function S(e,t,n){const o=new r(t,n);return w(o),p({error:o,key:e,namespace:v})}function b(r,s,i){if(T)return p({error:y,key:r,namespace:v});const w=y;let b,M;try{b=f(h,w,r,v)}catch(e){return S(r,o.MISSING_MESSAGE,e.message)}if("object"==typeof b){let e,t;return Array.isArray(b)?(e=o.INVALID_MESSAGE,t="Message at `".concat(a(v,r),"` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages")):(e=o.INSUFFICIENT_PATH,t="Message at `".concat(a(v,r),"` resolved to an object, but only strings are supported. Use a `.` to retrieve nested messages. See https://next-intl-docs.vercel.app/docs/usage/messages#structuring-messages")),S(r,e,t)}const I=function(e,t){if(t)return;const n=e.replace(/'([{}])/gi,"$1");return/<|{/.test(n)?void 0:n}(b,s);if(I)return I;d.getMessageFormat||(d.getMessageFormat=function(t,n){const r=c((function(){return new e(arguments.length<=0?void 0:arguments[0],arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],{formatters:n,...arguments.length<=3?void 0:arguments[3]})}),t.message);return r}(u,d));try{M=d.getMessageFormat(b,h,function(t,n){const r=n?{...t,dateTime:l(t.dateTime,n)}:t,o=e.formats.date,a=n?l(o,n):o,s=e.formats.time,i=n?l(s,n):s;return{...r,date:{...a,...r.dateTime},time:{...i,...r.dateTime}}}({...g,...i},E),{formatters:{...d,getDateTimeFormat:(e,t)=>d.getDateTimeFormat(e,{timeZone:E,...t})}})}catch(e){const t=e;return S(r,o.INVALID_MESSAGE,t.message+("originalMessage"in t?" (".concat(t.originalMessage,")"):""))}try{const e=M.format(function(e){if(0===Object.keys(e).length)return;const r={};return Object.keys(e).forEach((o=>{let a=0;const s=e[o];let i;i="function"==typeof s?e=>{const r=s(e);return t(r)?n(r,{key:o+a++}):r}:s,r[o]=i})),r}({...m,...s}));if(null==e)throw new Error("Unable to format `".concat(r,"` in ").concat(v?"namespace `".concat(v,"`"):"messages"));return t(e)||Array.isArray(e)||"string"==typeof e?e:String(e)}catch(e){return S(r,o.FORMATTING_ERROR,e.message)}}function M(e,t,n){const r=b(e,t,n);return"string"!=typeof r?S(e,o.INVALID_MESSAGE,"The message `".concat(e,"` in ").concat(v?"namespace `".concat(v,"`"):"messages"," didn't resolve to a string. If you want to format rich text, use `t.rich` instead.")):r}return M.rich=b,M.markup=(e,t,n)=>{const a=b(e,t,n);if("string"!=typeof a){const t=new r(o.FORMATTING_ERROR,"`t.markup` only accepts functions for formatting that receive and return strings.\n\nE.g. t.markup('markup', {b: (chunks) => `<b>${chunks}</b>`})");return w(t),p({error:t,key:e,namespace:v})}return a},M.raw=e=>{if(T)return p({error:y,key:e,namespace:v});const t=y;try{return f(h,t,e,v)}catch(t){return S(e,o.MISSING_MESSAGE,t.message)}},M.has=e=>{if(T)return!1;try{return f(h,y,e,v),!0}catch(e){return!1}},M}({...u,messagesOrError:m})}function d(e,t){return e===t?void 0:e.slice((t+".").length)}const p=60,h=60*p,y=24*h,v=7*y,w=y*(365/12),E=3*w,T=365*y,S={second:1,seconds:1,minute:p,minutes:p,hour:h,hours:h,day:y,days:y,week:v,weeks:v,month:w,months:w,quarter:E,quarters:E,year:T,years:T};function b(e){let{_cache:t=u(),_formatters:n=m(t),formats:a,locale:i,now:c,onError:l=s,timeZone:f}=e;function g(e){var t;return null!==(t=e)&&void 0!==t&&t.timeZone||(f?e={...e,timeZone:f}:l(new r(o.ENVIRONMENT_FALLBACK,"The `timeZone` parameter wasn't provided and there is no global default configured. Consider adding a global default to avoid markup mismatches caused by environment differences. Learn more: https://next-intl-docs.vercel.app/docs/configuration#time-zone"))),e}function d(e,t,n,a){let s;try{s=function(e,t){let n;if("string"==typeof t){const a=t;if(n=null==e?void 0:e[a],!n){const e=new r(o.MISSING_FORMAT,"Format `".concat(a,"` is not available. You can configure it on the provider or provide custom options."));throw l(e),e}}else n=t;return n}(t,e)}catch(e){return a()}try{return n(s)}catch(e){return l(new r(o.FORMATTING_ERROR,e.message)),a()}}function E(e,t){return d(t,null==a?void 0:a.dateTime,(t=>(t=g(t),n.getDateTimeFormat(i,t).format(e))),(()=>String(e)))}function b(){return c||(l(new r(o.ENVIRONMENT_FALLBACK,"The `now` parameter wasn't provided and there is no global default configured. Consider adding a global default to avoid markup mismatches caused by environment differences. Learn more: https://next-intl-docs.vercel.app/docs/configuration#now")),new Date)}return{dateTime:E,number:function(e,t){return d(t,null==a?void 0:a.number,(t=>n.getNumberFormat(i,t).format(e)),(()=>String(e)))},relativeTime:function(e,t){try{let r,o;const a={};t instanceof Date||"number"==typeof t?r=new Date(t):t&&(r=null!=t.now?new Date(t.now):b(),o=t.unit,a.style=t.style,a.numberingSystem=t.numberingSystem),r||(r=b());const s=(new Date(e).getTime()-r.getTime())/1e3;o||(o=function(e){const t=Math.abs(e);return t<p?"second":t<h?"minute":t<y?"hour":t<v?"day":t<w?"week":t<T?"month":"year"}(s)),a.numeric="second"===o?"auto":"always";const c=function(e,t){return Math.round(e/S[t])}(s,o);return n.getRelativeTimeFormat(i,a).format(c,o)}catch(t){return l(new r(o.FORMATTING_ERROR,t.message)),String(e)}},list:function(e,t){const r=[],o=new Map;let s=0;for(const t of e){let e;"object"==typeof t?(e=String(s),o.set(e,t)):e=String(t),r.push(e),s++}return d(t,null==a?void 0:a.list,(e=>{const t=n.getListFormat(i,e).formatToParts(r).map((e=>"literal"===e.type?e.value:o.get(e.value)||e.value));return o.size>0?t:t.join("")}),(()=>String(e)))},dateTimeRange:function(e,t,r){return d(r,null==a?void 0:a.dateTime,(r=>(r=g(r),n.getDateTimeFormat(i,r).formatRange(e,t))),(()=>[E(e),E(t)].join(" – ")))}}}export{g as a,b as c,d as r};