Skip to content

Latest commit

 

History

History
98 lines (71 loc) · 3.38 KB

File metadata and controls

98 lines (71 loc) · 3.38 KB

XCSAnalytics

XCSAnalytics provides read-only reporting helpers for catalogs. It computes key lists, locale lists, stale entries, key coverage, per-language progress, and overall statistics from the shared Catalog model.

Summary Types

KeyCoverageSummary

Fields:

  • key
  • locale
  • sourceLeafCount
  • translatedLeafCount
  • missingLeafCount
  • untranslatedLeafCount

Computed property:

  • coverage: translated leaf ratio for that key and locale scope

LanguageProgress

Fields:

  • locale
  • sourceLeafCount
  • translatedLeafCount
  • missingLeafCount
  • untranslatedLeafCount
  • needsReviewLeafCount

Computed property:

  • progress: completed-key ratio for that locale

Important detail: the leaf counts remain leaf-based, but progress is computed from completed translatable keys, not raw translated-leaf totals.

CatalogStatistics

Fields:

  • sourceLanguage
  • keyCount
  • targetLanguages
  • staleKeyCount
  • totalSourceLeafCount
  • translatedLeafCount
  • missingLeafCount
  • untranslatedLeafCount
  • languageProgress

Computed property:

  • overallCoverage: completed key-locale ratio across the catalog

Public API

public static func keys(in catalog: Catalog) -> [String]
public static func sourceLanguage(in catalog: Catalog) -> String
public static func targetLanguages(in catalog: Catalog) -> [String]
public static func localizations(forKey key: String, in catalog: Catalog) -> [String: Localization]
public static func translations(forKey key: String, in catalog: Catalog) -> [String: Localization]
public static func localization(forKey key: String, locale: String, in catalog: Catalog) -> Localization?
public static func sourceLocalization(forKey key: String, in catalog: Catalog) -> Localization?
public static func untranslatedKeys(in catalog: Catalog, locale: String) -> [String]
public static func staleKeys(in catalog: Catalog) -> [String]
public static func keyCoverage(forKey key: String, in catalog: Catalog) -> KeyCoverageSummary?
public static func keyCoverage(forKey key: String, locale: String, in catalog: Catalog) -> KeyCoverageSummary?
public static func languageProgress(in catalog: Catalog) -> [LanguageProgress]
public static func statistics(in catalog: Catalog) -> CatalogStatistics

Basic Usage

import XCSAnalytics

let keys = XCSAnalytics.keys(in: catalog)
let targetLocales = XCSAnalytics.targetLanguages(in: catalog)
let stale = XCSAnalytics.staleKeys(in: catalog)
let frenchGaps = XCSAnalytics.untranslatedKeys(in: catalog, locale: "fr")

let coverage = XCSAnalytics.keyCoverage(forKey: "Hello", locale: "fr", in: catalog)
let progress = XCSAnalytics.languageProgress(in: catalog)
let stats = XCSAnalytics.statistics(in: catalog)

Behavior Notes

  • Analytics synthesize a direct source leaf from entry.key when an entry has no explicit source-language localization.
  • Entries with shouldTranslate == false are excluded from analytics coverage and progress denominators.
  • Variant trees are flattened into leaf paths so plural and device leaves participate in coverage and progress.
  • Stale entries are reported by staleKeys(in:) and treated as incomplete for progress calculations.
  • targetLanguages(in:) excludes the source locale and returns a sorted list.

Use XCSAnalytics when you want reporting only. If you need to change the catalog, use XCSTranslator and XCSWriter.