refactor: 💡 prevent null lookups from being cached

This commit is contained in:
Christian Kaisermann 2019-11-20 22:20:56 -03:00
parent 6573f51e9b
commit a1dc268654

View File

@ -8,6 +8,7 @@ import { getGenericLocaleFrom } from './utils'
const lookupCache: Record<string, Record<string, string>> = {}
const addToCache = (path: string, locale: string, message: string) => {
if (!message) return message
if (!(locale in lookupCache)) lookupCache[locale] = {}
if (!(path in lookupCache[locale])) lookupCache[locale][path] = message
return message