Socket
Socket
Sign inDemoInstall

lookup-closest-locale

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.1.0 to 6.0.0-alpha.0

18

index.js

@@ -0,15 +1,15 @@

// @flow
// "lookup" algorithm http://tools.ietf.org/html/rfc4647#section-3.4
module.exports = function lookupClosestLocale (locale, available) {
if (available[locale]) return locale
var locales = [].concat(locale || [])
for (var l = 0, ll = locales.length; l < ll; ++l) {
var current = locales[l].split('-')
// assumes normalized language tags, and matches in a case sensitive manner
module.exports = function lookupClosestLocale (locale/*: string | string[] | void */, available/*: { [string]: any } */)/*: ?string */ {
if (typeof locale === 'string' && available[locale]) return locale
const locales = [].concat(locale || [])
for (let l = 0, ll = locales.length; l < ll; ++l) {
const current = locales[l].split('-')
while (current.length) {
if (current.join('-') in available) {
return current.join('-')
}
const candidate = current.join('-')
if (available[candidate]) return candidate
current.pop()
}
}
return 'en'
}
{
"name": "lookup-closest-locale",
"version": "5.1.0",
"version": "6.0.0-alpha.0",
"description": "Lookup the closest locale from among object keys",
"author": "Andy VanWagoner <thetalecrafter@gmail.com> (https://thetalecrafter.com/)",
"homepage": "https://github.com/format-message/format-message",
"author": "Andy VanWagoner <andy@thetalecrafter.com> (https://thetalecrafter.com/)",
"homepage": "https://github.com/format-message/format-message/tree/master/packages/lookup-closest-locale",
"license": "MIT",

@@ -11,4 +11,7 @@ "repository": "format-message/format-message",

"keywords": [
"format-message"
"i18n",
"lookup",
"BCP47",
"language tag"
]
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc