ihugang/swiftui-localization-skill
Overview
This skill is a SwiftUI Localization Expert for iOS and macOS projects. It scans, lints, and optionally applies localization fixes across .strings, .stringsdict, and .xcstrings files, and detects hardcoded SwiftUI text. It supports English and Simplified Chinese output selection and provides actionable reports for CI and developer workflows.
How this skill works
The skill discovers localization files via configurable glob patterns and identifies the base language (e.g., en.lproj or Base.lproj). It parses .strings and .stringsdict files line-by-line, reads .xcstrings as JSON, and extracts keys and values. It scans Swift source files for hardcoded UI text with strict allow/deny regex rules, validates key naming, checks placeholder consistency between base and target languages, runs plutil checks on plist formats, and can optionally verify Xcode builds after apply mode changes.
When to use it
- Run scan to generate a read-only inventory of localization keys and usage before refactor work.
- Run lint in CI to fail on hardcoded UI strings, invalid plist formats, naming rule violations, or placeholder mismatches.
- Run apply to automatically clean up, reformat, or insert missing keys and to generate AI-suggested translations (with review flags).
- Run when preparing a release to verify localization integrity and run plutil checks.
- Run before design/UI changes to detect strings likely to expand in translation and avoid layout breakage.
Best practices
- Default to scan mode for discovery; apply mode should be used only with a review step for AI-generated translations.
- Keep lang argument explicit (lang=en or lang=zh) to ensure consistent output language in automation.
- Treat possibly-unused keys as candidates for human review if dynamic key patterns exist in code.
- Preserve placeholders exactly; use positional placeholders when reordering is required.
- Run plutil after any modifications and run Xcode build verification as a separate optional CI step for large projects.
Example use cases
- CI lint job that fails the build if a new commit introduces hardcoded Text("...") or invalid .strings files.
- Repository audit: generate a key inventory, list unused keys, and export a translation-review.md for human validation.
- Automated apply pass to insert missing translations for a target locale, flagging all AI-generated strings for review.
- Pre-release validation to detect placeholder mismatches that could crash localized format calls.
- Developer pre-commit hook that scans modified .swift files for l10n-ignore exceptions and hardcoded UI text.
FAQ
English is the default. Use lang=zh for Simplified Chinese output.
Will apply mode automatically commit changes?
No. Apply performs file modifications but does not commit; you should review diffs and run plutil and optional build verification before committing.