Skip to content

About

Coverage, placeholder and Arabic plural checks for Xcode String Catalogs.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

xcstrings-audit dashboard with coverage bars and a percentage ring

CI Python 3.9+

xcstrings-audit

Xcode's percentage is not coverage.

The String Catalog editor counts an entry as done when it has a value, including entries whose state is new or needs_review. It also has no opinion about a translation that dropped a %@, or an Arabic plural that only defines other. Those are the failures users see first.

$ xca --missing Sources
1 catalog(s) · 7 keys · source: en

  ar       5/7      71%  ███████████░░░░░  missing 2 · review 1
  de       5/7      71%  ███████████░░░░░  missing 2

Placeholder mismatches (1)
  ar   Home.subtitle                placeholders differ: source has %@, %d, translation has %@

Plural categories (1)
  ar   items_count                  missing plural categories: zero, one, two, few, many

Stale keys (1)
  Old.title

Missing translations (4)
  ar   Profile.follow
  ar   Old.title
  de   Settings.language
  de   Old.title

How coverage is counted

filled / total per language, where a key counts as filled only if it has a non-empty value. needs_review and new count toward coverage but are reported separately, because a review backlog is a different problem from a missing string. The source language is tracked too, and hidden from the default view.

The checks

  • Missing / empty keys, listed with --missing.
  • Placeholders. %@, %lld, %.1f are compared as types and counts. %lld and %d are treated as equivalent. Plural entries are compared per category, other to other, so word order in %1$@ … %2$d does not produce a false alarm.
  • Arabic plurals. If an entry uses plural variations, the Arabic translation must have all six CLDR categories: zero, one, two, few, many, other.
  • Stale keys, from extractionState.
  • Badge. --badge writes a shields.io endpoint file with a colour based on coverage.

Install

git clone https://github.com/hfip/xcstrings-audit.git
cd xcstrings-audit
pipx install .

Both xcstrings-audit and xca are installed. Python 3.9+, no dependencies, 29 tests.

Everyday commands

xca Sources/                      # every .xcstrings under a folder
xca --lang ar .                   # one language
xca --missing .                   # print the keys, not just the count
xca --min-coverage 90 Sources/    # gate: exit 1 below 90%
xca --strict .                    # gate on any problem, including stale keys
xca --json . > report.json
xca --badge badge.json .          # shields.io endpoint for the README

--lang must exist in the catalogs. An unknown code exits 2 instead of quietly showing an empty report.

Exit codes: 0 clean, 1 gate failed, 2 usage or parse error.

Badge

![Arabic coverage](https://img.shields.io/endpoint?url=https://example.com/badge.json)

The badge is generated for the language you pass with --lang, otherwise for the language with the lowest coverage.

What it does not do

  • It never writes to the catalog. Safe on every pull request.
  • Only .xcstrings. Legacy .strings and .stringsdict are not parsed yet.
  • The plural rule set is Arabic-specific. Other languages get the placeholder and missing checks, not a category audit.
  • It cannot prove a translation is good, only that it is present and structurally intact.

بالعربي

نسبة التعريب في Xcode مضللة: تعتبر المفتاح منتهياً بمجرد ما يكون له قيمة، حتى لو حالته new أو needs_review. وما تنبهك إذا ضاع %@ من الترجمة، أو إذا الجمع العربي فيه other بس.

xcstrings-audit يقرأ الملف ويعطيك الصورة الحقيقية:

xca --missing .
xca --min-coverage 90 Sources/   # يفشل الـ CI إذا نزلت التغطية
xca --strict .                   # يفشل على أي مشكلة، مو بس النسبة

Part of the Arabic dev tools collection.

License

MIT. See LICENSE.

About

Coverage, placeholder and Arabic plural checks for Xcode String Catalogs.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages