Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
15 lines
644 B
Text
15 lines
644 B
Text
// @flow
|
|
// "lookup" algorithm http://tools.ietf.org/html/rfc4647#section-3.4
|
|
// 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
|
|
var locales = [].concat(locale || [])
|
|
for (var l = 0, ll = locales.length; l < ll; ++l) {
|
|
var current = locales[l].split('-')
|
|
while (current.length) {
|
|
var candidate = current.join('-')
|
|
if (available[candidate]) return candidate
|
|
current.pop()
|
|
}
|
|
}
|
|
}
|