From d503c045fba4e9ec459a464b2b0958ced3642820 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Fri, 4 Nov 2016 09:57:25 +0100 Subject: [PATCH] Use the iso639_2 to store the language in MP42Track. --- Classes/PropertyView/SBSoundViewController.m | 5 +++-- Classes/PropertyView/SBVideoViewController.m | 6 ++++-- Classes/SBDocument.m | 8 ++++---- Classes/SBFileImport.m | 3 ++- Classes/SBQueueAction.m | 2 +- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Classes/PropertyView/SBSoundViewController.m b/Classes/PropertyView/SBSoundViewController.m index 2b22674..eaf54b4 100755 --- a/Classes/PropertyView/SBSoundViewController.m +++ b/Classes/PropertyView/SBSoundViewController.m @@ -10,6 +10,7 @@ #import "SBMediaTagsController.h" #import +#import @implementation SBSoundViewController { @@ -54,7 +55,7 @@ NSMenuItem *newItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithFormat:@"%@ - %@ - %@", fileTrack.trackId ? [NSString stringWithFormat:@"%d", fileTrack.trackId] : @"na", fileTrack.name, - fileTrack.language] + [MP42Languages langForISO_639_2Code:fileTrack.language]] action:@selector(setFallbackTrack:) keyEquivalent:@""]; newItem.target = self; @@ -84,7 +85,7 @@ NSMenuItem *newItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithFormat:@"%@ - %@ - %@", fileTrack.trackId ? [NSString stringWithFormat:@"%d", fileTrack.trackId] : @"na", fileTrack.name, - fileTrack.language] + [MP42Languages langForISO_639_2Code:fileTrack.language]] action:@selector(setFollowsTrack:) keyEquivalent:@""]; newItem.target = self; diff --git a/Classes/PropertyView/SBVideoViewController.m b/Classes/PropertyView/SBVideoViewController.m index 2e0a0fa..2b433b7 100755 --- a/Classes/PropertyView/SBVideoViewController.m +++ b/Classes/PropertyView/SBVideoViewController.m @@ -8,7 +8,9 @@ #import "SBVideoViewController.h" #import "SBMediaTagsController.h" + #import +#import @interface SBVideoViewController () @@ -126,7 +128,7 @@ static NSString *getLevelName(uint8_t level) { [alternateGroup selectItemAtIndex:(NSInteger)track.alternate_group]; if (track.format == kMP42VideoCodecType_H264 && track.origProfile && track.origLevel) { - profileLevelUnchanged.title = [NSString stringWithFormat:@"Current profile: %@ @ %@", + profileLevelUnchanged.title = [NSString stringWithFormat:@"%@ %@ @ %@", NSLocalizedString(@"Current profile:", nil), getProfileName(track.origProfile), getLevelName(track.origLevel)]; if ((track.origProfile == track.newProfile) && (track.origLevel == track.newLevel)) { [videoProfile selectItemWithTag:1]; @@ -165,7 +167,7 @@ static NSString *getLevelName(uint8_t level) { NSMenuItem *newItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithFormat:@"%@ - %@ - %@", fileTrack.trackId ? [NSString stringWithFormat:@"%d", fileTrack.trackId] : @"NA", fileTrack.name, - fileTrack.language] + [MP42Languages langForISO_639_2Code:fileTrack.language]] action:@selector(setForcedTrack:) keyEquivalent:@""]; newItem.target = self; diff --git a/Classes/SBDocument.m b/Classes/SBDocument.m index e4b5295..d188da2 100644 --- a/Classes/SBDocument.m +++ b/Classes/SBDocument.m @@ -571,7 +571,7 @@ static NSDictionary *_detailMonospacedAttr; } else if ([tableColumn.identifier isEqualToString:@"trackLanguage"]) { SBComboBoxCellView *comboCell = [tableView makeViewWithIdentifier:@"ComboCell" owner:self]; - comboCell.comboBox.stringValue = track.language; + comboCell.comboBox.stringValue = [MP42Languages langForISO_639_2Code:track.language]; cell = comboCell; } } @@ -633,7 +633,7 @@ static NSDictionary *_detailMonospacedAttr; MP42Track *track = [self trackAtAtTableRow:row]; if (track && ![sender.stringValue isEqualToString:track.name]) { - track.language = sender.stringValue; + track.language = [MP42Languages ISO_639_2CodeForLang:sender.stringValue]; [self updateChangeCount:NSChangeDone]; } } @@ -648,9 +648,9 @@ static NSDictionary *_detailMonospacedAttr; return row - 1; } -- (MP42Track *)trackAtAtTableRow:(NSUInteger)row +- (MP42Track *)trackAtAtTableRow:(NSInteger)row { - if (row == 0) { + if (row <= 0) { return nil; } else { diff --git a/Classes/SBFileImport.m b/Classes/SBFileImport.m index d69cbf8..722fcac 100755 --- a/Classes/SBFileImport.m +++ b/Classes/SBFileImport.m @@ -10,6 +10,7 @@ #import #import #import +#import @interface SBFileImport () { @@ -347,7 +348,7 @@ } if ([tableColumn.identifier isEqualToString:@"trackLanguage"]) { - return track.language; + return [MP42Languages langForISO_639_2Code:track.language]; } if ([tableColumn.identifier isEqualToString:@"trackAction"]) { diff --git a/Classes/SBQueueAction.m b/Classes/SBQueueAction.m index e3b6d93..72bfcd7 100644 --- a/Classes/SBQueueAction.m +++ b/Classes/SBQueueAction.m @@ -402,7 +402,7 @@ - (void)runAction:(SBQueueItem *)item { for (MP42Track *track in item.mp4File.tracks) { - if ([track.language isEqualToString:@"Unknown"]) { + if ([track.language isEqualToString:@"und"]) { track.language = self.language; } }