-
Notifications
You must be signed in to change notification settings - Fork 668
feat(i18n-validator): add Zod-based runtime validation for i18n.json … #1461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(i18n-validator): add Zod-based runtime validation for i18n.json … #1461
Conversation
…with CLI and test suite
|
Hi, this is my first contribution to Lingo.dev! @maxprilutskiy I would love your feedback — I'm happy to refine anything if needed. 😊 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new package @lingo.dev/i18n-validator that provides runtime validation for i18n.json configuration files using Zod. The validator ensures localization configs follow the expected structure and provides smart suggestions for fixing common misconfigurations.
Key Changes:
- Zod-based schema validation for i18n.json spec v1.10 with support for locale, provider, formatter, and bucket configurations
- CLI tool (
lingo-validate-i18n) with colored output and helpful error messages - Programmatic API with TypeScript support for integration into build tools and CI/CD pipelines
- Comprehensive test suite with 12+ test scenarios covering valid configs, missing fields, and edge cases
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/i18n-validator/package.json | Package configuration with dependencies (chalk, zod), exports, and CLI bin entry |
| packages/i18n-validator/tsconfig.json | TypeScript configuration using ES2020 target and NodeNext module resolution |
| packages/i18n-validator/vitest.config.ts | Test configuration for Vitest with Node environment |
| packages/i18n-validator/src/schema.ts | Zod schema definitions for i18n.json v1.10 including locale, provider, formatter, and bucket configurations |
| packages/i18n-validator/src/validate.ts | Core validation function with custom checks for [locale] placeholders in bucket paths |
| packages/i18n-validator/src/suggest.ts | Error message transformation logic that converts Zod errors into actionable suggestions |
| packages/i18n-validator/src/cli.ts | CLI implementation with file reading, JSON parsing, and colored terminal output |
| packages/i18n-validator/src/index.ts | Public API exports for programmatic usage |
| packages/i18n-validator/test/validate.test.ts | Comprehensive test suite covering valid configs, missing fields, invalid values, and edge cases |
| packages/i18n-validator/README.md | Documentation with usage examples, API reference, and integration guides |
| pnpm-lock.yaml | Lockfile updates for new dependencies (chalk, zod, vitest v1.6.1, and their transitive dependencies) |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hi @maxprilutskiy |
✨ Summary
This PR introduces a new package
@lingo.dev/i18n-validatorthat performs runtime validation ofi18n.jsonfiles using Zod.It ensures that localization configurations follow the expected structure and provides helpful suggestions for fixing invalid or incomplete configs.
🚀 Features
i18n.json(schema v1.10)[locale]placeholders in bucket pathslingo-validate-i18nwith colorized output and exit codes🧪 Testing
To test locally:
Expected:
or programatically:
🧩 Motivation
This contribution enhances Lingo.dev’s developer experience by allowing users to:
🧾 Notes
Thank you for reviewing! 🙏
Happy to make any adjustments based on feedback.