(flatMap, existingFlatMap, manifest, localeState)
| 331 | |
| 332 | // Build nested structure from flat keys |
| 333 | function buildNestedObject(flatMap, existingFlatMap, manifest, localeState) { |
| 334 | const result = {}; |
| 335 | let missingCount = 0; |
| 336 | let staleCount = 0; |
| 337 | |
| 338 | for (const [key, value] of Object.entries(flatMap)) { |
| 339 | const parts = key.split('.'); |
| 340 | let current = result; |
| 341 | |
| 342 | for (let i = 0; i < parts.length - 1; i++) { |
| 343 | const part = parts[i]; |
| 344 | if (!current[part]) { |
| 345 | current[part] = {}; |
| 346 | } |
| 347 | current = current[part]; |
| 348 | } |
| 349 | |
| 350 | const lastPart = parts[parts.length - 1]; |
| 351 | const sourceHash = manifest[key]; |
| 352 | const entry = normalizeStateEntry(localeState[key]); |
| 353 | |
| 354 | // Check if translation is missing or stale using same logic as verify |
| 355 | const isMissing = !localeState[key] || !entry.translation; |
| 356 | const isStale = !isMissing && entry.source !== sourceHash; |
| 357 | |
| 358 | if (isMissing) { |
| 359 | current[lastPart] = `TODO: ${value}`; |
| 360 | missingCount++; |
| 361 | } else if (isStale) { |
| 362 | current[lastPart] = `STALE: ${existingFlatMap[key] || value}`; |
| 363 | staleCount++; |
| 364 | } else { |
| 365 | current[lastPart] = existingFlatMap[key]; |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | return { result, missingCount, staleCount }; |
| 370 | } |
| 371 | |
| 372 | const { result: nestedStructure, missingCount, staleCount } = buildNestedObject(sourceMap, existingMap, manifest, localeState); |
| 373 |
no test coverage detected