Skip to content

Conversation

@PriyaJainDev
Copy link

✨ Summary

This PR introduces a new package @lingo.dev/i18n-validator that performs runtime validation of i18n.json files using Zod.

It ensures that localization configurations follow the expected structure and provides helpful suggestions for fixing invalid or incomplete configs.


🚀 Features

  • Zod-based runtime validation for i18n.json (schema v1.10)
  • 💡 Smart suggestions for missing or misconfigured fields
  • ⚙️ Custom validation rules for [locale] placeholders in bucket paths
  • 🧠 CLI utility: lingo-validate-i18n with colorized output and exit codes
  • 🧪 Comprehensive test coverage (12+ Vitest test cases)
  • 🧰 Full TypeScript support and build-ready package structure

🧪 Testing

To test locally:

pnpm install
pnpm --filter @lingo.dev/i18n-validator build
pnpm --filter @lingo.dev/i18n-validator test

Expected:

lingo-validate-i18n
lingo-validate-i18n ./config/i18n.json

or programatically:

import { validateI18nConfig } from "@lingo.dev/i18n-validator";

const result = validateI18nConfig({ locale: { source: "en", targets: ["es"] } });
console.log(result.ok ? "✅ Valid" : result.errors);


🧩 Motivation

This contribution enhances Lingo.dev’s developer experience by allowing users to:

  • Validate their i18n.json before running translations,
  • Catch schema or key errors early,
  • Integrate checks into CI/CD pipelines.

🧾 Notes

  • Package: @lingo.dev/i18n-validator
  • Added under packages/i18n-validator/
  • Includes source, CLI, tests, and documentation.

Thank you for reviewing! 🙏

Happy to make any adjustments based on feedback.

@PriyaJainDev
Copy link
Author

PriyaJainDev commented Oct 31, 2025

Hi, this is my first contribution to Lingo.dev!
I built a runtime validator for i18n.json using Zod to help developers catch config issues early.

@maxprilutskiy I would love your feedback — I'm happy to refine anything if needed. 😊

Copy link
Contributor

Copilot AI left a 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.

@PriyaJainDev
Copy link
Author

Hi @maxprilutskiy
I've updated the PR as per Co-Pilot suggestions. Kindly review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant