i18next-http-middleware
Advanced tools
Comparing version 3.5.0 to 3.6.0
@@ -118,2 +118,7 @@ import { | ||
cookieDomain?: string; | ||
/** | ||
* optional conversion function to use to modify the detected language code | ||
*/ | ||
convertDetectedLanguage?: 'Iso15897' | ((lng: string) => string); | ||
} | ||
@@ -120,0 +125,0 @@ interface LanguageDetectorAllOptions { |
@@ -32,3 +32,6 @@ "use strict"; | ||
cookieSameSite: 'strict', | ||
ignoreCase: true | ||
ignoreCase: true, | ||
convertDetectedLanguage: function convertDetectedLanguage(l) { | ||
return l; | ||
} | ||
}); | ||
@@ -53,2 +56,7 @@ } | ||
this.allOptions = allOptions; | ||
if (typeof this.options.convertDetectedLanguage === 'string' && this.options.convertDetectedLanguage.indexOf('15897') > -1) { | ||
this.options.convertDetectedLanguage = function (l) { | ||
return l.replace('-', '_'); | ||
}; | ||
} | ||
this.addDetector(_cookie.default); | ||
@@ -80,2 +88,5 @@ this.addDetector(_querystring.default); | ||
}); | ||
detections = detections.map(function (d) { | ||
return _this.options.convertDetectedLanguage(d); | ||
}); | ||
if (_this.services.languageUtils.getBestMatchFromCodes) { | ||
@@ -82,0 +93,0 @@ found = _this.services.languageUtils.getBestMatchFromCodes(detections); |
@@ -118,2 +118,7 @@ import { | ||
cookieDomain?: string; | ||
/** | ||
* optional conversion function to use to modify the detected language code | ||
*/ | ||
convertDetectedLanguage?: 'Iso15897' | ((lng: string) => string); | ||
} | ||
@@ -120,0 +125,0 @@ interface LanguageDetectorAllOptions { |
@@ -23,3 +23,6 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } | ||
cookieSameSite: 'strict', | ||
ignoreCase: true | ||
ignoreCase: true, | ||
convertDetectedLanguage: function convertDetectedLanguage(l) { | ||
return l; | ||
} | ||
}); | ||
@@ -44,2 +47,7 @@ } | ||
this.allOptions = allOptions; | ||
if (typeof this.options.convertDetectedLanguage === 'string' && this.options.convertDetectedLanguage.indexOf('15897') > -1) { | ||
this.options.convertDetectedLanguage = function (l) { | ||
return l.replace('-', '_'); | ||
}; | ||
} | ||
this.addDetector(cookieLookup); | ||
@@ -71,2 +79,5 @@ this.addDetector(querystringLookup); | ||
}); | ||
detections = detections.map(function (d) { | ||
return _this.options.convertDetectedLanguage(d); | ||
}); | ||
if (_this.services.languageUtils.getBestMatchFromCodes) { | ||
@@ -73,0 +84,0 @@ found = _this.services.languageUtils.getBestMatchFromCodes(detections); |
@@ -118,2 +118,7 @@ import { | ||
cookieDomain?: string; | ||
/** | ||
* optional conversion function to use to modify the detected language code | ||
*/ | ||
convertDetectedLanguage?: 'Iso15897' | ((lng: string) => string); | ||
} | ||
@@ -120,0 +125,0 @@ interface LanguageDetectorAllOptions { |
@@ -23,3 +23,5 @@ import * as utils from './utils.js' | ||
cookieSameSite: 'strict', | ||
ignoreCase: true | ||
ignoreCase: true, | ||
convertDetectedLanguage: (l) => l | ||
}) | ||
@@ -41,2 +43,6 @@ } | ||
if (typeof this.options.convertDetectedLanguage === 'string' && this.options.convertDetectedLanguage.indexOf('15897') > -1) { | ||
this.options.convertDetectedLanguage = (l) => l.replace('-', '_') | ||
} | ||
this.addDetector(cookieLookup) | ||
@@ -66,2 +72,3 @@ this.addDetector(querystringLookup) | ||
detections = detections.filter((d) => d !== undefined && d !== null) | ||
detections = detections.map((d) => this.options.convertDetectedLanguage(d)) | ||
@@ -68,0 +75,0 @@ if (this.services.languageUtils.getBestMatchFromCodes) { // new i18next v19.5.0 |
{ | ||
"name": "i18next-http-middleware", | ||
"version": "3.5.0", | ||
"version": "3.6.0", | ||
"private": false, | ||
@@ -47,3 +47,3 @@ "type": "module", | ||
"expect.js": "0.3.1", | ||
"express": "4.18.2", | ||
"express": "4.19.2", | ||
"fastify": "4.24.3", | ||
@@ -50,0 +50,0 @@ "i18next": "23.7.1", |
@@ -401,3 +401,7 @@ # Introduction | ||
cookieSecure: true, // if need secure cookie | ||
cookieSameSite: 'strict' // 'strict', 'lax' or 'none' | ||
cookieSameSite: 'strict', // 'strict', 'lax' or 'none' | ||
// optional conversion function used to modify the detected language code | ||
convertDetectedLanguage: 'Iso15897', | ||
convertDetectedLanguage: (lng) => lng.replace('-', '_') | ||
} | ||
@@ -404,0 +408,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
144347
2931
484