Skip to content

Latest commit

 

History

History
70 lines (49 loc) · 1.67 KB

File metadata and controls

70 lines (49 loc) · 1.67 KB

XCSValidator

XCSValidator performs read-only semantic analysis on a parsed catalog and returns structured findings. It never mutates the Catalog it receives.

Public API

ValidationSeverity

  • info
  • warning
  • error

ValidationCategory

  • missingLocalizations
  • missingSourceLocalization
  • incompleteLocalization
  • untranslatedValue
  • needsReview
  • placeholderMismatch

ValidationFinding

Each finding includes:

  • severity
  • category
  • message
  • path
  • entryKey
  • locale

Validation Entry Point

public static func validate(_ catalog: Catalog) -> [ValidationFinding]

Basic Usage

import XCSParser
import XCSValidator

let catalog = try XCSParser.parse(fileURL: catalogURL)
let findings = XCSValidator.validate(catalog)

for finding in findings {
    print("\(finding.severity.rawValue): \(finding.path): \(finding.message)")
}

What The Validator Checks

Current validation covers:

  • entries with no localizations at all
  • entries missing a source-language localization
  • localizations that contain neither a direct leaf nor any variation leaf
  • non-source leaves marked needs_review
  • non-source leaves that exist but are not translated
  • placeholder mismatches between source leaves and matching target leaves

Behavior Notes

  • Findings are sorted deterministically by path, category, and locale.
  • Placeholder checking applies to direct leaves and matching variant leaves.
  • The validator does not infer fixes, rewrite the catalog, or call external services.

If you want to act on translation gaps after validation, pair this module with XCSTranslator and XCSWriter.