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

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

📋 Pull Request Information

Original PR: https://github.com/CCExtractor/ccextractor/pull/2038
Author: @cfsmp3
Created: 1/18/2026
Status: Merged
Merged: 1/19/2026
Merged by: @cfsmp3

Base: masterHead: fix/mkvlang-extended-codes


📝 Commits (2)

  • 91d3512 fix(rust): Support BCP 47 language tags in --mkvlang option
  • 298665f chore: fix cargo fmt formatting

📊 Changes

6 files changed (+404 additions, -30 deletions)

View changed files

📝 docs/CHANGES.TXT (+1 -0)
src/rust/lib_ccxr/src/common/mkv_lang.rs (+385 -0)
📝 src/rust/lib_ccxr/src/common/mod.rs (+2 -0)
📝 src/rust/lib_ccxr/src/common/options.rs (+3 -2)
📝 src/rust/src/common.rs (+6 -7)
📝 src/rust/src/parser.rs (+7 -21)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/CCExtractor/ccextractor/pull/2038 **Author:** [@cfsmp3](https://github.com/cfsmp3) **Created:** 1/18/2026 **Status:** ✅ Merged **Merged:** 1/19/2026 **Merged by:** [@cfsmp3](https://github.com/cfsmp3) **Base:** `master` ← **Head:** `fix/mkvlang-extended-codes` --- ### 📝 Commits (2) - [`91d3512`](https://github.com/CCExtractor/ccextractor/commit/91d3512bcc4e57dbb26b2d178fe0da0cc6062679) fix(rust): Support BCP 47 language tags in --mkvlang option - [`298665f`](https://github.com/CCExtractor/ccextractor/commit/298665faa4db62b281f64aa1e50cfd14b8b8d3cc) chore: fix cargo fmt formatting ### 📊 Changes **6 files changed** (+404 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `docs/CHANGES.TXT` (+1 -0) ➕ `src/rust/lib_ccxr/src/common/mkv_lang.rs` (+385 -0) 📝 `src/rust/lib_ccxr/src/common/mod.rs` (+2 -0) 📝 `src/rust/lib_ccxr/src/common/options.rs` (+3 -2) 📝 `src/rust/src/common.rs` (+6 -7) 📝 `src/rust/src/parser.rs` (+7 -21) </details> ### 📄 Description ## 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 17:24:13 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#2845