next-intl 4.8.2 → 4.8.3

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.
@@ -13,6 +13,9 @@ function orderLocales(locales) {
13
13
  // Workaround for https://github.com/formatjs/formatjs/issues/4469
14
14
  return locales.slice().sort((a, b) => b.length - a.length);
15
15
  }
16
+ function mapToProvidedLocale(locales, locale) {
17
+ return locales.find(cur => cur.toLowerCase() === locale.toLowerCase());
18
+ }
16
19
  function getAcceptLanguageLocale(requestHeaders, locales, defaultLocale) {
17
20
  let locale;
18
21
  const languages = new Negotiator({
@@ -22,7 +25,7 @@ function getAcceptLanguageLocale(requestHeaders, locales, defaultLocale) {
22
25
  }).languages();
23
26
  try {
24
27
  const orderedLocales = orderLocales(locales);
25
- locale = match(languages, orderedLocales, defaultLocale);
28
+ locale = mapToProvidedLocale(locales, match(languages, orderedLocales, defaultLocale));
26
29
  } catch {
27
30
  // Invalid language
28
31
  }
@@ -1 +1 @@
1
- import{match as e}from"@formatjs/intl-localematcher";import o from"negotiator";import{getPathnameMatch as l,isLocaleSupportedOnDomain as t,getHost as a}from"./utils.js";function c(l,t,a){let c;const n=new o({headers:{"accept-language":l.get("accept-language")||void 0}}).languages();try{const o=function(e){return e.slice().sort(((e,o)=>o.length-e.length))}(t);c=e(n,o,a)}catch{}return c}function n(e,o){if(e.localeCookie&&o.has(e.localeCookie.name)){const l=o.get(e.localeCookie.name)?.value;if(l&&e.locales.includes(l))return l}}function i(e,o,t,a){let i;return a&&(i=l(a,e.locales,e.localePrefix)?.locale),!i&&e.localeDetection&&(i=n(e,t)),!i&&e.localeDetection&&(i=c(o,e.locales,e.defaultLocale)),i||(i=e.defaultLocale),i}function r(e,o,r,f){const u=function(e,o){const l=a(e);if(l)return o.find((e=>e.domain===l))}(o,e.domains);if(!u)return{locale:i(e,o,r,f)};let s;if(f){const o=l(f,e.locales,e.localePrefix,u)?.locale;if(o){if(!t(o,u))return{locale:o,domain:u};s=o}}if(!s&&e.localeDetection){const o=n(e,r);o&&t(o,u)&&(s=o)}if(!s&&e.localeDetection){const e=c(o,u.locales,u.defaultLocale);e&&(s=e)}return s||(s=u.defaultLocale),{locale:s,domain:u}}function f(e,o,l,t){return e.domains?r(e,o,l,t):{locale:i(e,o,l,t)}}export{f as default,c as getAcceptLanguageLocale};
1
+ import{match as e}from"@formatjs/intl-localematcher";import o from"negotiator";import{getPathnameMatch as l,isLocaleSupportedOnDomain as t,getHost as n}from"./utils.js";function a(l,t,n){let a;const c=new o({headers:{"accept-language":l.get("accept-language")||void 0}}).languages();try{const o=function(e){return e.slice().sort(((e,o)=>o.length-e.length))}(t);a=function(e,o){return e.find((e=>e.toLowerCase()===o.toLowerCase()))}(t,e(c,o,n))}catch{}return a}function c(e,o){if(e.localeCookie&&o.has(e.localeCookie.name)){const l=o.get(e.localeCookie.name)?.value;if(l&&e.locales.includes(l))return l}}function i(e,o,t,n){let i;return n&&(i=l(n,e.locales,e.localePrefix)?.locale),!i&&e.localeDetection&&(i=c(e,t)),!i&&e.localeDetection&&(i=a(o,e.locales,e.defaultLocale)),i||(i=e.defaultLocale),i}function r(e,o,r,f){const u=function(e,o){const l=n(e);if(l)return o.find((e=>e.domain===l))}(o,e.domains);if(!u)return{locale:i(e,o,r,f)};let s;if(f){const o=l(f,e.locales,e.localePrefix,u)?.locale;if(o){if(!t(o,u))return{locale:o,domain:u};s=o}}if(!s&&e.localeDetection){const o=c(e,r);o&&t(o,u)&&(s=o)}if(!s&&e.localeDetection){const e=a(o,u.locales,u.defaultLocale);e&&(s=e)}return s||(s=u.defaultLocale),{locale:s,domain:u}}function f(e,o,l,t){return e.domains?r(e,o,l,t):{locale:i(e,o,l,t)}}export{f as default,a as getAcceptLanguageLocale};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-intl",
3
- "version": "4.8.2",
3
+ "version": "4.8.3",
4
4
  "sideEffects": false,
5
5
  "author": "Jan Amann <jan@amann.work>",
6
6
  "funding": [
@@ -124,14 +124,14 @@
124
124
  "next.js"
125
125
  ],
126
126
  "dependencies": {
127
- "@formatjs/intl-localematcher": "^0.5.4",
127
+ "@formatjs/intl-localematcher": "^0.8.1",
128
128
  "@parcel/watcher": "^2.4.1",
129
129
  "@swc/core": "^1.15.2",
130
- "icu-minify": "^4.8.2",
130
+ "icu-minify": "^4.8.3",
131
131
  "negotiator": "^1.0.0",
132
- "next-intl-swc-plugin-extractor": "^4.8.2",
132
+ "next-intl-swc-plugin-extractor": "^4.8.3",
133
133
  "po-parser": "^2.1.1",
134
- "use-intl": "^4.8.2"
134
+ "use-intl": "^4.8.3"
135
135
  },
136
136
  "peerDependencies": {
137
137
  "next": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
@@ -143,5 +143,5 @@
143
143
  "optional": true
144
144
  }
145
145
  },
146
- "gitHead": "de4baeb465185133923b69c8da36457c9418d781"
146
+ "gitHead": "099bfebe5048b036a76520381daac7635d2640e1"
147
147
  }