i18n-keyless-core 2.6.0 → 2.6.1
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/package.json +1 -1
- package/dist/service.js +4 -2
- package/package.json +1 -1
package/dist/package.json
CHANGED
package/dist/service.js
CHANGED
|
@@ -84,8 +84,10 @@ export function getTranslationCore(key, store, options) {
|
|
|
84
84
|
.map((key) => key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"))
|
|
85
85
|
.join("|");
|
|
86
86
|
const regex = new RegExp(pattern, "g");
|
|
87
|
-
// Replace all occurrences in a single pass
|
|
88
|
-
|
|
87
|
+
// Replace all occurrences in a single pass. `translation` can be undefined
|
|
88
|
+
// when the current language's translation hasn't arrived yet (translateKey
|
|
89
|
+
// was just queued above) — fall back to the key like the no-replace path.
|
|
90
|
+
return (translation || key).replace(regex, (matched) => options.replace?.[matched] || matched);
|
|
89
91
|
}
|
|
90
92
|
const translating = {};
|
|
91
93
|
/**
|