diff --git a/MP42/MP42AACImporter.mm b/MP42/MP42AACImporter.mm index adeb814..d01ef21 100644 --- a/MP42/MP42AACImporter.mm +++ b/MP42/MP42AACImporter.mm @@ -747,7 +747,8 @@ static bool GetFirstHeader(FILE* inFile) if (!GetFirstHeader(inFile)) { if (outError) { - *outError = MP42Error(@"The audio could not be opened.", @"Data in file doesn't appear to be valid audio.", 100); + *outError = MP42Error(MP42LocalizedString(@"The audio could not be opened.", @"error message"), + MP42LocalizedString(@"Data in file doesn't appear to be valid audio.", @"error message"), 100); } [newTrack release]; return nil; @@ -759,7 +760,8 @@ static bool GetFirstHeader(FILE* inFile) if (aacProfileLevel == 2) { if (profile > MP4_MPEG4_AAC_SSR_AUDIO_TYPE) { if (outError) { - *outError = MP42Error(@"The audio could not be opened.", @"Can't convert profile to mpeg2", 100); + *outError = MP42Error(MP42LocalizedString(@"The audio could not be opened.", @"error message"), + MP42LocalizedString(@"Can't convert profile to mpeg2", @"error message"), 100); } [newTrack release]; return nil; @@ -788,7 +790,8 @@ static bool GetFirstHeader(FILE* inFile) break; case 3: if (outError) { - *outError = MP42Error(@"The audio could not be opened.", @"Data in file doesn't appear to be valid audio.", 100); + *outError = MP42Error(MP42LocalizedString(@"The audio could not be opened.", @"error message"), + MP42LocalizedString(@"Data in file doesn't appear to be valid audio.", @"error message"), 100); } [newTrack release]; return nil; diff --git a/MP42/MP42ChapterTrack.m b/MP42/MP42ChapterTrack.m index 8fd305d..04e76b0 100644 --- a/MP42/MP42ChapterTrack.m +++ b/MP42/MP42ChapterTrack.m @@ -250,7 +250,7 @@ if (!success) { if (outError != NULL) - *outError = MP42Error(@"Failed to mux chapters into mp4 file", + *outError = MP42Error(MP42LocalizedString(@"Failed to mux chapters into mp4 file", @"error message"), nil, 120); @@ -287,7 +287,9 @@ NSArray *lineFields = csvData[i]; if (lineFields.count != 2 || [lineFields[0] integerValue] != i + 1) { if (NULL != outError) - *outError = MP42Error(@"Invalid chapters CSV file.", @"The CSV file is not a valid chapters CSV file.", 150); + *outError = MP42Error(MP42LocalizedString(@"Invalid chapters CSV file.", @"error message"), + MP42LocalizedString(@"The CSV file is not a valid chapters CSV file.", @"error message"), + 150); return NO; } } @@ -298,7 +300,9 @@ return YES; } if (NULL != outError) - *outError = MP42Error(@"Incorrect line count", @"The line count in the chapters CSV file does not match the number of chapters in the movie.", 151); + *outError = MP42Error(MP42LocalizedString(@"Incorrect line count", @"error message"), + MP42LocalizedString(@"The line count in the chapters CSV file does not match the number of chapters in the movie.", @"error message"), + 151); return NO; } diff --git a/MP42/MP42File.m b/MP42/MP42File.m index f25346f..a3730f6 100644 --- a/MP42/MP42File.m +++ b/MP42/MP42File.m @@ -162,7 +162,8 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { if (![self startReading]) { if (error) { - *error = MP42Error(@"The movie could not be opened.", @"The file is not a mp4 file.", 100); + *error = MP42Error(MP42LocalizedString(@"The movie could not be opened.", @"error message"), + MP42LocalizedString(@"The file is not a mp4 file.", @"error message"), 100); [_logger writeErrorToLog:*error]; } return nil; @@ -177,7 +178,8 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { [self stopReading]; if (error) { - *error = MP42Error(@"Invalid File Type.", @"MOV File cannot be edited.", 100); + *error = MP42Error(MP42LocalizedString(@"Invalid File Type.", @"error message"), + MP42LocalizedString(@"MOV File cannot be edited.", @"error message"), 100); [_logger writeErrorToLog:*error]; } @@ -190,7 +192,8 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { [self stopReading]; if (error) { - *error = MP42Error(@"Invalid File Type.", @"Fragmented MP4 cannot be edited.", 100); + *error = MP42Error(MP42LocalizedString(@"Invalid File Type.", @"error message"), + MP42LocalizedString(@"Fragmented MP4 cannot be edited.", @"error message"), 100); [_logger writeErrorToLog:*error]; } @@ -622,7 +625,8 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { if (!url) { if (outError) { - *outError = MP42Error(@"Invalid path.", @"The destination path cannot be empty.", 100); + *outError = MP42Error(MP42LocalizedString(@"Invalid path.", @"error message"), + MP42LocalizedString(@"The destination path cannot be empty.", @"error message"), 100); [_logger writeErrorToLog:*outError]; } return NO; @@ -632,7 +636,8 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { NSURL *sourceURL = track.URL.filePathURL; if ([sourceURL isEqualTo:url]) { if (outError) { - *outError = MP42Error(@"Invalid destination.", @"Can't overwrite the source movie.", 100); + *outError = MP42Error(MP42LocalizedString(@"Invalid destination.", @"error"), + MP42LocalizedString(@"Can't overwrite the source movie.", @"error message"), 100); [_logger writeErrorToLog:*outError]; } return NO; @@ -672,7 +677,8 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { else { success = NO; if (outError) { - *outError = MP42Error(@"The file could not be saved.", @"You do not have sufficient permissions for this operation.", 101); + *outError = MP42Error(MP42LocalizedString(@"The file could not be saved.", @"error message"), + MP42LocalizedString(@"You do not have sufficient permissions for this operation.", @"error message"), 101); [_logger writeErrorToLog:*outError]; } } @@ -725,7 +731,8 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { } else { success = NO; if (outError) { - *outError = MP42Error(@"The file could not be saved.", @"You do not have sufficient permissions for this operation.", 101); + *outError = MP42Error(MP42LocalizedString(@"The file could not be saved.", @"error message"), + MP42LocalizedString(@"You do not have sufficient permissions for this operation.", @"error message"), 101); [_logger writeErrorToLog:*outError]; } } @@ -739,7 +746,9 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { // Open the mp4 file if (![self startWriting]) { if (outError) { - *outError = MP42Error(@"The file could not be saved.", @"You may do not have sufficient permissions for this operation, or the mp4 file is corrupted.", 101); + *outError = MP42Error(MP42LocalizedString(@"The file could not be saved.", @"error message"), + MP42LocalizedString(@"You may do not have sufficient permissions for this operation, or the mp4 file is corrupted.", @"error message"), + 101); [_logger writeErrorToLog:*outError]; } return NO; @@ -773,7 +782,8 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { track.importer = fileImporter; } else { if (outError) { - NSError *error = MP42Error(@"Missing sources.", @"One or more sources files are missing.", 200); + NSError *error = MP42Error(MP42LocalizedString(@"Missing sources.", @"error message"), + MP42LocalizedString(@"One or more sources files are missing.", @"error message"), 200); [_logger writeErrorToLog:error]; if (outError) { *outError = error; } } @@ -789,7 +799,7 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { } else { // We don't know how to handle this type of track. // Just drop it. - NSError *error = MP42Error(@"Unsupported track", + NSError *error = MP42Error(MP42LocalizedString(@"Unsupported track", @"error message"), [NSString stringWithFormat:@"%@, %u, has not been muxed.", track.name, (unsigned int)track.format], 201); @@ -833,8 +843,8 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) { // Close the mp4 file handle if (![self stopWriting]) { if (outError) { - *outError = MP42Error(@"File excedes 4 GB.", - @"The file is bigger than 4 GB, but it was created with 32bit data chunk offset.\nSelect 64bit data chunk offset in the save panel.", + *outError = MP42Error(MP42LocalizedString(@"File excedes 4 GB.", @"error message"), + MP42LocalizedString(@"The file is bigger than 4 GB, but it was created with 32bit data chunk offset.\nSelect 64bit data chunk offset in the save panel.", @"error message"), 102); [_logger writeErrorToLog:*outError]; } diff --git a/MP42/MP42MkvImporter.m b/MP42/MP42MkvImporter.m index 3289e74..0603eba 100644 --- a/MP42/MP42MkvImporter.m +++ b/MP42/MP42MkvImporter.m @@ -170,7 +170,8 @@ static int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, ui if (!_matroskaFile) { if (outError) { - *outError = MP42Error(@"The movie could not be opened.", @"The file is not a matroska file.", 100); + *outError = MP42Error(MP42LocalizedString(@"The movie could not be opened.", @"mkv error message"), + MP42LocalizedString(@"The file is not a matroska file.", @"mkv error message"), 100); } [self release]; diff --git a/MP42/MP42PrivateUtilities.h b/MP42/MP42PrivateUtilities.h index a0c8e65..725e5c5 100644 --- a/MP42/MP42PrivateUtilities.h +++ b/MP42/MP42PrivateUtilities.h @@ -11,6 +11,10 @@ #import "MP42Utilities.h" #include "mp4v2.h" +#define MP42BundleIdentifier @"org.galad.MP42Foundation" + +#define MP42LocalizedString(key, comment) NSLocalizedStringFromTableInBundle(key, @"Localizable", (NSBundle *__nonnull)([NSBundle bundleWithIdentifier:MP42BundleIdentifier] ? [NSBundle bundleWithIdentifier:MP42BundleIdentifier] : [NSBundle mainBundle]), comment) + #ifdef __cplusplus extern "C" { #endif @@ -22,7 +26,7 @@ typedef enum { TRACK_DISABLED = 0x0, TRACK_IN_POSTER = 0x8 } track_header_flags; -NSString* SRTStringFromTime( long long time, long timeScale , const char separator); +NSString * SRTStringFromTime( long long time, long timeScale , const char separator); int MP4SetTrackEnabled(MP4FileHandle fileHandle, MP4TrackId trackId); int MP4SetTrackDisabled(MP4FileHandle fileHandle, MP4TrackId trackId); diff --git a/MP42/MP42SrtImporter.m b/MP42/MP42SrtImporter.m index 3892ba1..ffdcf86 100644 --- a/MP42/MP42SrtImporter.m +++ b/MP42/MP42SrtImporter.m @@ -103,7 +103,8 @@ if (!success) { if (outError) { - *outError = MP42Error(@"The file could not be opened.", @"The file is not a srt file, or it does not contain any subtitles.", 100); + *outError = MP42Error(MP42LocalizedString(@"The file could not be opened.", @"srt error message"), + MP42LocalizedString(@"The file is not a srt file, or it does not contain any subtitles.", @"srt error message"), 100); } [newTrack release]; diff --git a/MP42/MP42SubtitleTrack.m b/MP42/MP42SubtitleTrack.m index 05cfe78..e102cd2 100644 --- a/MP42/MP42SubtitleTrack.m +++ b/MP42/MP42SubtitleTrack.m @@ -79,7 +79,7 @@ { if (!fileHandle || !self.trackId) { if ( outError != NULL) { - *outError = MP42Error(@"Error: couldn't mux subtitle track", + *outError = MP42Error(MP42LocalizedString(@"Error: couldn't mux subtitle track", @"error message"), nil, 120); return NO; diff --git a/MP42/MP42Track.m b/MP42/MP42Track.m index 1075fb1..56b2baf 100644 --- a/MP42/MP42Track.m +++ b/MP42/MP42Track.m @@ -196,7 +196,7 @@ if (!fileHandle || !_trackId) { if ( outError != NULL) { - *outError = MP42Error(@"Failed to modify track", + *outError = MP42Error(MP42LocalizedString(@"Failed to modify track", @"error message"), nil, 120); return NO; diff --git a/MP42/MP42VobSubImporter.m b/MP42/MP42VobSubImporter.m index 3c0613b..c87aca9 100644 --- a/MP42/MP42VobSubImporter.m +++ b/MP42/MP42VobSubImporter.m @@ -252,7 +252,8 @@ static NSArray * LoadVobSubSubtitles(NSURL *theDirectory, NSStr if (!self.tracks.count) { if (outError) { - *outError = MP42Error(@"The file could not be opened.", @"The file is not a idx file, or it does not contain any subtitles.", 100); + *outError = MP42Error(MP42LocalizedString(@"The file could not be opened.", @"vobsub error message"), + MP42LocalizedString(@"The file is not a idx file, or it does not contain any subtitles.", @"vobsub error message"), 100); } [self release];