{"_id":"i18n-state-manager","name":"i18n-state-manager","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"i18n-state-manager","version":"0.1.0","description":"Git-native translation management with intelligent stale detection. Hash-based state tracking ensures your translations stay synchronized with your code.","type":"module","main":"src/core.mjs","bin":{"i18n-state":"bin/i18n-state.mjs"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":["i18n","internationalization","translation","localization","l10n","translations","state-management","stale-detection","git-native","typescript","react","vue","angular"],"author":{"name":"Callum Alpass"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/callumalpass/i18n-state-manager.git"},"bugs":{"url":"https://github.com/callumalpass/i18n-state-manager/issues"},"homepage":"https://github.com/callumalpass/i18n-state-manager#readme","engines":{"node":">=16.0.0"},"devDependencies":{},"dependencies":{},"gitHead":"155fcc8e4d168042873e3f14be8e8449a0f8dea8","_id":"i18n-state-manager@0.1.0","_nodeVersion":"20.19.5","_npmVersion":"11.6.2","dist":{"integrity":"sha512-5sTZYTcLwzuPFvP36RA9eQFOTYddoB93jFzFPs+Zh2v+crwZSmvnZ51JN0q7Q8hPZTFpQWnvRqB7WPr+RuSezA==","shasum":"9ad377aa09e79f8bca92a8ee25f0d3cbb14e9c29","tarball":"https://registry.npmjs.org/i18n-state-manager/-/i18n-state-manager-0.1.0.tgz","fileCount":6,"unpackedSize":41720,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICO7JMgU7g//w3iDr7vTbPv3n9f+P80x03XglwatS2FwAiEA6//MUY6c/iQ+q1lYasnl5iJxiJGF73rvUo0F0+sdtEg="}]},"_npmUser":{"name":"callumalpass","email":"callumalpass@gmail.com"},"directories":{},"maintainers":[{"name":"callumalpass","email":"callumalpass@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/i18n-state-manager_0.1.0_1762224795231_0.5754338098235394"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-04T02:53:15.230Z","0.1.0":"2025-11-04T02:53:15.423Z","modified":"2025-11-04T02:53:15.708Z"},"maintainers":[{"name":"callumalpass","email":"callumalpass@gmail.com"}],"description":"Git-native translation management with intelligent stale detection. Hash-based state tracking ensures your translations stay synchronized with your code.","homepage":"https://github.com/callumalpass/i18n-state-manager#readme","keywords":["i18n","internationalization","translation","localization","l10n","translations","state-management","stale-detection","git-native","typescript","react","vue","angular"],"repository":{"type":"git","url":"git+https://github.com/callumalpass/i18n-state-manager.git"},"author":{"name":"Callum Alpass"},"bugs":{"url":"https://github.com/callumalpass/i18n-state-manager/issues"},"license":"MIT","readme":"# i18n-state-manager\n\n> Git-native translation management with intelligent stale detection\n\n[![npm version](https://img.shields.io/npm/v/i18n-state-manager.svg)](https://www.npmjs.com/package/i18n-state-manager)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n## The Problem\n\nMost translation management tools can detect missing translations, but they cannot identify when translations become outdated.\n\nWhen you change source text from \"Click to save\" to \"Click to save changes\", other languages still reference the old translation. Traditional tools don't catch this because the translation technically exists.\n\n## The Solution\n\ni18n-state-manager uses hash-based state tracking to detect three translation states:\n\n- **Up-to-date** - Translation matches current source text\n- **Missing** - Translation doesn't exist\n- **Stale** - Translation exists but source text changed\n\n## Requirements\n\n- Node.js >= 16.0.0\n- [ripgrep](https://github.com/BurntSushi/ripgrep) (required for `check-usage` and `find-unused` commands)\n\nInstall ripgrep:\n```bash\n# macOS\nbrew install ripgrep\n\n# Ubuntu/Debian\napt install ripgrep\n\n# Arch Linux\npacman -S ripgrep\n\n# Fedora\ndnf install ripgrep\n\n# Windows\nchoco install ripgrep\n```\n\n## Quick Start\n\n```bash\n# Install\nnpm install -D i18n-state-manager\n\n# Initialize\nnpx i18n-state init\n\n# Sync translations\nnpx i18n-state sync\n\n# Check status\nnpx i18n-state verify\n```\n\n## Features\n\n### Core Features\n\n- **Hash-based stale detection** - Track when translations become outdated\n- **Git-trackable state** - State files commit alongside your code\n- **Zero cloud dependencies** - Everything runs locally\n- **CI/CD enforcement** - Prevent untranslated strings from being deployed\n- **Template generation** - Create translation files with TODO/STALE markers\n\n### Developer Experience\n\n- **7 commands** - Complete workflow coverage\n- **Static code analysis** - Finds translation keys in your code\n- **Unused key detection** - Clean up legacy translations\n- **Duplicate detection** - Catch copy-paste errors\n- **TypeScript support** - First-class TypeScript integration\n\n## How It Works\n\n### 1. Manifest File (`i18n.manifest.json`)\n\nContains SHA1 hashes of all source language strings:\n\n```json\n{\n  \"common.save\": \"a94a8fe5ccb19ba61c4c0873d391e987982fbbd3\",\n  \"common.cancel\": \"c3499c2729730a7f807efb8676a92dcb6f8a3f8f\"\n}\n```\n\n### 2. State File (`i18n.state.json`)\n\nTracks translation status for each locale:\n\n```json\n{\n  \"fr\": {\n    \"common.save\": {\n      \"source\": \"a94a8fe5ccb19ba61c4c0873d391e987982fbbd3\",\n      \"translation\": \"5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8\"\n    }\n  }\n}\n```\n\n### 3. Intelligent Detection\n\nWhen English changes from \"Save\" to \"Save changes\":\n- Manifest hash updates\n- State hash doesn't match\n- System marks translation as **stale**\n\n## Commands\n\n### `i18n-state sync`\nUpdate manifest and state files after changing translations.\n\n### `i18n-state verify`\nCheck for missing and stale translations (fails on issues - perfect for CI).\n\n```bash\n$ npx i18n-state verify\n\nTranslation Statistics:\n  fr: 1465/1540 (95%) up-to-date, 0 stale\n  de: 1487/1540 (97%) up-to-date, 0 stale\n\nMissing translations:\n  [fr] 75 missing keys:\n    - settings.newFeature.title\n    - settings.newFeature.description\n    ...\n```\n\n### `i18n-state status`\nShow translation coverage summary (non-failing).\n\n### `i18n-state check-usage`\nFind translation keys used in code and verify they exist in source locale.\n\n```bash\n$ npx i18n-state check-usage\n\nFound 1172 unique translation keys in source code\n\nKeys used in code but missing from en.ts:\n  - modals.newModal.title\n```\n\n### `i18n-state find-unused`\nFind keys in source locale that aren't used in source code.\n\n### `i18n-state check-duplicates`\nCheck for duplicate keys in translation files.\n\n### `i18n-state generate-template <locale>`\nGenerate a translation template file.\n\n```bash\n$ npx i18n-state generate-template fr\n\nStatistics:\n  Total keys: 1540\n  Up-to-date: 1465\n  Missing: 75\n  Stale: 0\n\n# Template file contains:\n# - Existing translations (preserved)\n# - Missing keys marked \"TODO: English text\"\n# - Stale keys marked \"STALE: old translation\"\n```\n\n## Configuration\n\nCreate `i18n-state.config.json`:\n\n```json\n{\n  \"sourceLocale\": \"en\",\n  \"resourcesDir\": \"src/i18n/resources\",\n  \"manifestPath\": \"i18n.manifest.json\",\n  \"statePath\": \"i18n.state.json\",\n  \"scanDirs\": [\"src\"],\n  \"scanExtensions\": [\"ts\", \"tsx\", \"js\", \"jsx\"],\n  \"patterns\": [\n    {\n      \"name\": \"t()\",\n      \"regex\": \"\\\\bt\\\\([\\\"']([^\\\"']+)[\\\"']\\\\)\"\n    },\n    {\n      \"name\": \"translate()\",\n      \"regex\": \"\\\\btranslate\\\\([\\\"']([^\\\"']+)[\\\"']\\\\)\"\n    }\n  ]\n}\n```\n\n## Typical Workflow\n\n### Adding New Features\n\n```bash\n# 1. Add English strings\n# Edit src/i18n/resources/en.ts\n\n# 2. Update manifest/state\nnpx i18n-state sync\n\n# 3. Generate templates for other locales\nnpx i18n-state generate-template fr\nnpx i18n-state generate-template de\n\n# 4. Translate TODO items in *.template.ts files\n\n# 5. Verify everything\nnpx i18n-state verify\n```\n\n### CI/CD Integration\n\nAdd to your GitHub Actions workflow:\n\n```yaml\n- name: Check translations are up-to-date\n  run: |\n    npm run i18n-state sync\n    if [[ -n \"$(git status --porcelain)\" ]]; then\n      echo \"Translation files are out of date\"\n      exit 1\n    fi\n    npm run i18n-state verify\n```\n\n## Translation File Format\n\nCurrently supports TypeScript (.ts) files only:\n\n```typescript\nimport { Translation } from \"../types\";\n\nexport const fr: Translation = {\n  common: {\n    save: \"Enregistrer\",\n    cancel: \"Annuler\",\n  },\n  settings: {\n    title: \"Paramètres\",\n  }\n};\n```\n\nNote: JSON and JavaScript formats are not currently supported. Translation files must be TypeScript files with the structure shown above.\n\n## Comparison\n\n| Feature | i18n-state-manager | i18n-tasks | Locize | react-intl |\n|---------|-------------------|------------|---------|------------|\n| Stale detection | Hash-based | No | Timestamp-based | No |\n| Local-first | Yes | Yes | Cloud-only | Yes |\n| Find unused keys | Yes | Yes | Yes | Basic |\n| CI/CD enforcement | Yes | Manual | Yes | No |\n| Template generation | Yes | No | Web UI | No |\n| Cost | Free | Free | $500+/mo | Free |\n\n## Contributing\n\nContributions welcome! Please read our [Contributing Guide](CONTRIBUTING.md).\n\n## License\n\nMIT © Callum Alpass\n\n## Acknowledgments\n\nDeveloped as part of [TaskNotes](https://github.com/callumalpass/tasknotes), an Obsidian plugin for task management.\n","readmeFilename":"README.md","_rev":"1-b849f557eaf881d84bc70e8d06ad6651"}