Improve MKV LanguageBCP47 conversion

This commit is contained in:
Damiano Galassi committed 2026-08-27 16:51:13 +02:00
1 parent 65acfeb7cd
commit 740fd075b3
3 files changed
+14 -3

No files matched your search

+12 -2
View File
@@ -817,8 +817,18 @@ MP42_OBJC_DIRECT_MEMBERS
#pragma mark - Validation
- (BOOL)validateExtendedTag:(NSString *)tag {
NSString *fixedCode = [tag stringByReplacingOccurrencesOfString:@"-" withString:@"_"];
return [NSLocale.availableLocaleIdentifiers containsObject:fixedCode];
NSString *fixedTag = [tag stringByReplacingOccurrencesOfString:@"-" withString:@"_"];
return [NSLocale.availableLocaleIdentifiers containsObject:fixedTag];
}
- (nullable NSString *)normalizedExtendedTag:(NSString *)tag {
NSString *fixedTag = [tag stringByReplacingOccurrencesOfString:@"-" withString:@"_"];
for (NSString *identifier in NSLocale.availableLocaleIdentifiers) {
if ([identifier caseInsensitiveCompare:fixedTag] == NSOrderedSame) {
return [identifier stringByReplacingOccurrencesOfString:@"_" withString:@"-"];
}
}
return tag;
}