Skip to content

feat: plural rules engine, validation reports, CLI integration, and autofix#4

Merged
WendellXY merged 10 commits intomainfrom
feature/plural-rules-engine
Sep 1, 2025
Merged

feat: plural rules engine, validation reports, CLI integration, and autofix#4
WendellXY merged 10 commits intomainfrom
feature/plural-rules-engine

Conversation

@WendellXY
Copy link
Copy Markdown
Collaborator

@WendellXY WendellXY commented Sep 1, 2025

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:

  • Added a --check-plurals flag to the view command in langcodec-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]
  • Exposed plural validation and autofix functions in the core library API (validate_plurals, collect_plural_issues, autofix_fill_missing_from_other) and re-exported them in lib.rs for CLI and library consumers. [1] [2] [3]

Plural completeness reporting in stats:

  • Improved the stats output in the CLI to include counts of missing plural entries and missing plural categories per language, using the new plural validation functions. [1] [2] [3] [4] [5]

Testing and validation:

  • Added integration tests for the CLI to ensure --check-plurals correctly fails when plural categories are missing and passes when they are complete.

Documentation and roadmap updates:

  • Updated the roadmap to mark plural rules engine and CLDR-driven validation as in progress or complete, reflecting the new features.
  • Updated documentation links and release notes to reflect the new version and features. [1] [2]

Dependency and packaging improvements:

  • Updated CLI dependency on langcodec to use a local path for development consistency.

These changes provide robust plural validation for localization workflows and improve reporting and developer experience.

- 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
Copilot AI review requested due to automatic review settings September 1, 2025 16:28
Copy link
Copy Markdown
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 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.

Comment thread langcodec/src/plural_rules.rs Outdated
- Track added categories per entry (added_here)
- Only mark the current entry as NeedsReview when it changed
@WendellXY WendellXY merged commit 060ecae into main Sep 1, 2025
7 checks passed
@WendellXY WendellXY deleted the feature/plural-rules-engine branch September 1, 2025 16:38
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.

2 participants