MCPcopy Create free account
hub / github.com/5e-bits/5e-database / _refreshLocaleStatsForLang

Function _refreshLocaleStatsForLang

scripts/update/processor.ts:366–386  ·  view source on GitHub ↗
(db: Db, filepath: string, lang: string)

Source from the content-addressed store, hash-verified

364// --- Translation Handlers ---
365
366async 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
388async function _handleTranslationFileAdded(db: Db, filepath: string): Promise<void> {
389 const ctx = await resolveTranslationContext(filepath);

Calls 1

getCollectionPrefixFunction · 0.90

Tested by

no test coverage detected