MCPcopy
hub / github.com/mashpie/i18n-node / getFallback

Function getFallback

i18n.js:1357–1368  ·  view source on GitHub ↗
(targetLocale, fallbacks)

Source from the content-addressed store, hash-verified

1355 * Get locales with wildcard support
1356 */
1357 const getFallback = (targetLocale, fallbacks) => {
1358 fallbacks = fallbacks || {}
1359 if (fallbacks[targetLocale]) return fallbacks[targetLocale]
1360 let fallBackLocale = null
1361 for (const key in fallbacks) {
1362 if (targetLocale.match(new RegExp('^' + key.replace('*', '.*') + '$'))) {
1363 fallBackLocale = fallbacks[key]
1364 break
1365 }
1366 }
1367 return fallBackLocale
1368 }
1369
1370 /**
1371 * Logging proxies

Callers 3

i18nFunction · 0.85
guessLanguageFunction · 0.85
translateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected