feat: plural rules engine, validation reports, CLI integration, and autofix#4
Merged
feat: plural rules engine, validation reports, CLI integration, and autofix#4
Conversation
- Add module with CLDR-like required category sets per locale - Add and exports - Add to aggregate per-resource errors
- Validate plural completeness per locale with exit status
- Add tests for missing and complete English plural forms
- Validate plural completeness per locale with exit status
- Add tests for missing and complete English plural forms
- Replace match-based rules with lazy_static BTreeMap keyed by base language
- Remove region/script variants unreachable with base-language selection
- Keep conservative default to {Other}
- Add PluralValidationReport with missing/have sets
- Add collect_resource_plural_issues and Codec::collect_plural_issues
- Refactor validate_plurals to fold reports into an Error
…achable variants
- Replace match-based rules with lazy_static BTreeMap keyed by base language
- Remove region/script variants unreachable with base-language selection
- Keep conservative default to {Other}
- Validate plural completeness per locale with exit status
- Add tests for missing and complete English plural forms
- Replace match-based rules with lazy_static BTreeMap keyed by base language
- Remove region/script variants unreachable with base-language selection
- Keep conservative default to {Other}
- Add PluralValidationReport with missing/have sets
- Add collect_resource_plural_issues and Codec::collect_plural_issues
- Refactor validate_plurals to fold reports into an Error
- Add PluralValidationReport with missing/have sets
- Add collect_resource_plural_issues and Codec::collect_plural_issues
- Refactor validate_plurals to fold reports into an Error
- Replace match-based rules with lazy_static BTreeMap keyed by base language
- Remove region/script variants unreachable with base-language selection
- Keep conservative default to {Other}
- Add PluralValidationReport with missing/have sets
- Add collect_resource_plural_issues and Codec::collect_plural_issues
- Refactor validate_plurals to fold reports into an Error
- Per-language counts of entries with missing plural categories
- Total missing plural categories per language
- Add PluralValidationReport with missing/have sets - Add collect_resource_plural_issues and Codec::collect_plural_issues - Refactor validate_plurals to fold reports into an Error - Per-language counts of entries with missing plural categories - Total missing plural categories per language - Resource-level: autofix_fill_missing_from_other_resource - Codec-level: autofix_fill_missing_from_other - Skips DoNotTranslate entries; sets NeedsReview when autofilling
…+ JSON) - Per-language counts of entries with missing plural categories - Total missing plural categories per language - Per-language counts of entries with missing plural categories - Total missing plural categories per language - Resource-level: autofix_fill_missing_from_other_resource - Codec-level: autofix_fill_missing_from_other - Skips DoNotTranslate entries; sets NeedsReview when autofilling
…'other' and mark NeedsReview - Resource-level: autofix_fill_missing_from_other_resource - Codec-level: autofix_fill_missing_from_other - Skips DoNotTranslate entries; sets NeedsReview when autofilling - Per-language counts of entries with missing plural categories - Total missing plural categories per language - Resource-level: autofix_fill_missing_from_other_resource - Codec-level: autofix_fill_missing_from_other - Skips DoNotTranslate entries; sets NeedsReview when autofilling
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements a comprehensive plural rules engine with CLDR-style validation, CLI integration, and autofix functionality. The implementation adds robust plural category validation for localization files to ensure completeness across different languages.
- Adds CLDR-style plural rules engine with static category tables for common locales
- Introduces non-fatal validation reports and autofix capabilities for missing plural categories
- Integrates plural validation into CLI commands and statistics output
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
langcodec/src/plural_rules.rs |
Core plural rules engine with CLDR category mappings, validation logic, and autofix functionality |
langcodec/src/lib.rs |
Exports new plural rules module and key functions |
langcodec/src/codec.rs |
Adds plural validation and autofix methods to Codec, improves language inference |
langcodec/README.md |
Minor URL formatting fix |
langcodec-cli/tests/plural_validation_cli_tests.rs |
Test suite for CLI plural validation functionality |
langcodec-cli/src/stats.rs |
Adds plural validation statistics to output |
langcodec-cli/src/main.rs |
Integrates --check-plurals flag into view command |
langcodec-cli/Cargo.toml |
Updates dependency to use local path |
ROADMAP.md |
Updates progress on plural rules engine features |
README.md |
Minor formatting adjustment |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- Track added categories per entry (added_here) - Only mark the current entry as NeedsReview when it changed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces plural rules validation features to the CLI and core library, improves plural completeness reporting in stats, and updates documentation and roadmap to reflect these enhancements. The most significant changes are grouped below:
Plural validation feature in CLI and core library:
--check-pluralsflag to theviewcommand inlangcodec-cli, enabling validation of plural completeness against CLDR category sets. If validation fails, the CLI exits with an error and a descriptive message. [1] [2] [3] [4]validate_plurals,collect_plural_issues,autofix_fill_missing_from_other) and re-exported them inlib.rsfor CLI and library consumers. [1] [2] [3]Plural completeness reporting in stats:
Testing and validation:
--check-pluralscorrectly fails when plural categories are missing and passes when they are complete.Documentation and roadmap updates:
Dependency and packaging improvements:
langcodecto use a local path for development consistency.These changes provide robust plural validation for localization workflows and improve reporting and developer experience.