int QAChecker::Check(CatalogItemPtr item) { int issues = 0; for (auto& c: m_checks) { if (item->GetString().empty() || (item->HasPlural() && item->GetPluralString().empty())) continue; if (c->CheckItem(item)) issues++; } return issues; }
bool QACheck::CheckItem(CatalogItemPtr item) { if (!item->GetTranslation().empty() && CheckString(item, item->GetString(), item->GetTranslation())) return true; if (item->HasPlural()) { unsigned count = item->GetNumberOfTranslations(); for (unsigned i = 1; i < count; i++) { auto t = item->GetTranslation(i); if (!t.empty() && CheckString(item, item->GetPluralString(), t)) return true; } } return false; }
bool CheckItem(CatalogItemPtr item) override { if (!item->HasPlural()) return false; bool foundTranslated = false; bool foundEmpty = false; for (auto& s: item->GetTranslations()) { if (s.empty()) foundEmpty = true; else foundTranslated = true; } if (foundEmpty && foundTranslated) { item->SetIssue(CatalogItem::Issue::Warning, _("Not all plural forms are translated.")); return true; } return false; }