@formatjs/intl-localematcher 0.5.3 → 0.5.4
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/abstract/utils.js +4 -3
- package/lib/abstract/utils.js +4 -3
- package/package.json +1 -1
package/abstract/utils.js
CHANGED
|
@@ -149,10 +149,11 @@ function findBestMatch(requestedLocales, supportedLocales, threshold) {
|
|
|
149
149
|
if (!result.distances[desired]) {
|
|
150
150
|
result.distances[desired] = {};
|
|
151
151
|
}
|
|
152
|
-
supportedLocales.forEach(function (supported
|
|
152
|
+
supportedLocales.forEach(function (supported) {
|
|
153
153
|
// Add some weight to the distance based on the order of the supported locales
|
|
154
|
-
// Add penalty for the order of the requested locales
|
|
155
|
-
|
|
154
|
+
// Add penalty for the order of the requested locales, which currently is 0 since ECMA-402
|
|
155
|
+
// doesn't really have room for weighted locales like `en; q=0.1`
|
|
156
|
+
var distance = findMatchingDistance(desired, supported) + 0 + i * 40;
|
|
156
157
|
result.distances[desired][supported] = distance;
|
|
157
158
|
if (distance < lowestDistance) {
|
|
158
159
|
lowestDistance = distance;
|
package/lib/abstract/utils.js
CHANGED
|
@@ -144,10 +144,11 @@ export function findBestMatch(requestedLocales, supportedLocales, threshold) {
|
|
|
144
144
|
if (!result.distances[desired]) {
|
|
145
145
|
result.distances[desired] = {};
|
|
146
146
|
}
|
|
147
|
-
supportedLocales.forEach(function (supported
|
|
147
|
+
supportedLocales.forEach(function (supported) {
|
|
148
148
|
// Add some weight to the distance based on the order of the supported locales
|
|
149
|
-
// Add penalty for the order of the requested locales
|
|
150
|
-
|
|
149
|
+
// Add penalty for the order of the requested locales, which currently is 0 since ECMA-402
|
|
150
|
+
// doesn't really have room for weighted locales like `en; q=0.1`
|
|
151
|
+
var distance = findMatchingDistance(desired, supported) + 0 + i * 40;
|
|
151
152
|
result.distances[desired][supported] = distance;
|
|
152
153
|
if (distance < lowestDistance) {
|
|
153
154
|
lowestDistance = distance;
|