(db: Db, filepath: string, lang: string)
| 364 | // --- Translation Handlers --- |
| 365 | |
| 366 | async function _refreshLocaleStatsForLang(db: Db, filepath: string, lang: string): Promise<void> { |
| 367 | const collectionPrefix = getCollectionPrefix(filepath); |
| 368 | |
| 369 | const localeCollection = db.collection(`${collectionPrefix}locales`); |
| 370 | const hasTranslations = |
| 371 | (await db |
| 372 | .collection(`${collectionPrefix}translations`) |
| 373 | .countDocuments({ lang }, { limit: 1 })) > 0; |
| 374 | |
| 375 | if (hasTranslations) { |
| 376 | await localeCollection.updateOne( |
| 377 | { lang }, |
| 378 | { $set: { lang, updated_at: new Date() } }, |
| 379 | { upsert: true } |
| 380 | ); |
| 381 | console.log(` Updated locale entry for '${lang}'.`); |
| 382 | } else { |
| 383 | await localeCollection.deleteOne({ lang }); |
| 384 | console.log(` Removed locale entry for '${lang}' (no translations remaining).`); |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | async function _handleTranslationFileAdded(db: Db, filepath: string): Promise<void> { |
| 389 | const ctx = await resolveTranslationContext(filepath); |
no test coverage detected