[PR #2038] fix(rust): Support BCP 47 language tags in --mkvlang option #2850

Closed
opened 2026-01-29 17:24:14 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/CCExtractor/ccextractor/pull/2038

State: closed
Merged: Yes


Summary

The --mkvlang option previously only supported single ISO 639-2 codes due to using a Language enum with a fixed list of variants. Extended codes (like fre-ca) and multiple codes (like eng,chi) would panic with "VariantNotFound".

This change introduces MkvLangFilter, a proper type for language filtering that:

  • Validates language codes per BCP 47 specification
  • Supports ISO 639-2 (3-letter codes like eng)
  • Supports BCP 47 tags (like en-US, zh-Hans-CN)
  • Supports comma-separated multiple codes
  • Provides clean error messages for invalid input
  • Includes comprehensive unit tests (8 tests)

The C code continues to receive the raw string for strstr() matching, maintaining backward compatibility.

Test plan

  • Build passes
  • Unit tests pass (cargo test mkv_lang)
  • Manual testing:
    • --mkvlang eng,fre - works
    • --mkvlang en-US,fr-CA - works (previously crashed)
    • --mkvlang zh-Hans-CN - works (previously crashed)
    • --mkvlang a - clean error message
    • --mkvlang ç - clean error message (previously panicked)

🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/CCExtractor/ccextractor/pull/2038 **State:** closed **Merged:** Yes --- ## Summary The `--mkvlang` option previously only supported single ISO 639-2 codes due to using a `Language` enum with a fixed list of variants. Extended codes (like `fre-ca`) and multiple codes (like `eng,chi`) would panic with "VariantNotFound". This change introduces `MkvLangFilter`, a proper type for language filtering that: - Validates language codes per BCP 47 specification - Supports ISO 639-2 (3-letter codes like `eng`) - Supports BCP 47 tags (like `en-US`, `zh-Hans-CN`) - Supports comma-separated multiple codes - Provides clean error messages for invalid input - Includes comprehensive unit tests (8 tests) The C code continues to receive the raw string for `strstr()` matching, maintaining backward compatibility. ## Test plan - [x] Build passes - [x] Unit tests pass (`cargo test mkv_lang`) - [x] Manual testing: - `--mkvlang eng,fre` - works - `--mkvlang en-US,fr-CA` - works (previously crashed) - `--mkvlang zh-Hans-CN` - works (previously crashed) - `--mkvlang a` - clean error message - `--mkvlang ç` - clean error message (previously panicked) 🤖 Generated with [Claude Code](https://claude.ai/code)
claunia added the pull-request label 2026-01-29 17:24:14 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2850