From 8c0fa52e3356f19bfd18f035244f4f5aa88ff4b3 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 1 Dec 2024 20:02:07 -0400 Subject: language: unflattenLanguageSpec: fix dropping own nodes early recovers many strings! --- src/data/language.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/data/language.js b/src/data/language.js index b8f58efd..3edf7e51 100644 --- a/src/data/language.js +++ b/src/data/language.js @@ -110,7 +110,13 @@ export function unflattenLanguageSpec(flat, reference) { } if (typeof result === 'string') { - delete ownNode[firstKey]; + // When an algorithm faces a corner case, don't rethink the algorithm; + // hard-code the right thing to do. + if (typeof ownNode[firstKey] === 'object' && empty(restKeys) && ownNode[firstKey]._) { + delete ownNode[firstKey]._; + } else { + delete ownNode[firstKey]; + } return {[firstKey]: result}; } -- cgit 1.3.0-6-gf8a5