@lovalingo/lovalingo 0.2.0 → 0.2.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.
@@ -376,7 +376,7 @@ export function setActiveTranslations(translations) {
376
376
  }
377
377
  const map = new Map();
378
378
  for (const t of translations) {
379
- const source = (t?.source_text || "").toString().trim();
379
+ const source = normalizeWhitespace((t?.source_text || "").toString());
380
380
  const translated = (t?.translated_text ?? "").toString();
381
381
  if (!source || !translated)
382
382
  continue;
@@ -389,7 +389,7 @@ function applyTranslationMap(bundle, root) {
389
389
  return 0;
390
390
  const map = new Map();
391
391
  for (const [k, v] of Object.entries(bundle || {})) {
392
- const source = (k || "").toString().trim();
392
+ const source = normalizeWhitespace((k || "").toString());
393
393
  const translated = (v ?? "").toString();
394
394
  if (!source || !translated)
395
395
  continue;
@@ -426,7 +426,8 @@ export function applyActiveTranslations(root = document.body) {
426
426
  if (!isTranslatableText(trimmed))
427
427
  continue;
428
428
  const original = getOrInitTextOriginal(textNode, parent);
429
- const translation = map.get(original.trimmed);
429
+ const key = normalizeWhitespace(original.trimmed);
430
+ const translation = map.get(key);
430
431
  if (!translation)
431
432
  continue;
432
433
  const next = `${original.leading}${translation}${original.trailing}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovalingo/lovalingo",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "React translation runtime with i18n routing, deterministic bundles + DOM rules, and zero-flash rendering.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",