@payloadcms/translations 3.0.0-alpha.11 → 3.0.0-alpha.13
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/dist/utilities/init.js +4 -3
- package/package.json +1 -1
package/dist/utilities/init.js
CHANGED
|
@@ -157,7 +157,7 @@ const initTFunction = (args) => (key, vars) => {
|
|
|
157
157
|
};
|
|
158
158
|
function memoize(fn, keys) {
|
|
159
159
|
const cacheMap = new Map();
|
|
160
|
-
|
|
160
|
+
const memoized = (args) => {
|
|
161
161
|
const cacheKey = keys.reduce((acc, key) => acc + args[key], '');
|
|
162
162
|
if (!cacheMap.has(cacheKey)) {
|
|
163
163
|
const result = fn(args);
|
|
@@ -165,8 +165,9 @@ function memoize(fn, keys) {
|
|
|
165
165
|
}
|
|
166
166
|
return cacheMap.get(cacheKey);
|
|
167
167
|
};
|
|
168
|
+
return memoized;
|
|
168
169
|
}
|
|
169
|
-
exports.initI18n = memoize((
|
|
170
|
+
exports.initI18n = memoize(({ config, language = 'en', translations, context }) => {
|
|
170
171
|
const i18n = {
|
|
171
172
|
fallbackLanguage: config.fallbackLanguage,
|
|
172
173
|
language: language || config.fallbackLanguage,
|
|
@@ -177,4 +178,4 @@ exports.initI18n = memoize((({ config, language = 'en', translations, context })
|
|
|
177
178
|
}),
|
|
178
179
|
};
|
|
179
180
|
return i18n;
|
|
180
|
-
}
|
|
181
|
+
}, ['language', 'context']);
|