Skip to content

Commit a2e95fa

Browse files
committed
Fix web stats calculation to handle plural forms correctly
- Replace manual key counting with ResourceFile.Count property - Replace manual translation counting with ResourceFile.CompletedCount - CompletedCount uses ResourceEntry.IsEmpty which correctly handles plurals - Fixes invalid stats for JSON/PO/Android/iOS projects with plural forms - Aligns with CLI stats command implementation
1 parent 1bb6faf commit a2e95fa

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

Controllers/StatsController.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,13 @@ public ActionResult<StatsResponse> GetStats()
3838
return StatusCode(500, new { error = "No default language file found" });
3939
}
4040

41-
var totalKeys = defaultFile.Entries.Select(e => e.Key).Distinct().Count();
41+
// Use ResourceFile.Count for total keys (handles plurals correctly)
42+
var totalKeys = defaultFile.Count;
4243

4344
var languageStats = resourceFiles.Select(file =>
4445
{
45-
var translatedCount = file.Entries
46-
.Where(e => !string.IsNullOrWhiteSpace(e.Value))
47-
.Select(e => e.Key)
48-
.Distinct()
49-
.Count();
46+
// Use ResourceFile.CompletedCount (handles plurals correctly via IsEmpty property)
47+
var translatedCount = file.CompletedCount;
5048

5149
var coverage = totalKeys > 0 ? (double)translatedCount / totalKeys * 100 : 0;
5250

0 commit comments

Comments
 (0)