Made the error message localisable.
This commit is contained in:
1 parent
384d30d00c
commit
6f31037011
9 files changed
+48
-24
No files matched your search
@@ -747,7 +747,8 @@ static bool GetFirstHeader(FILE* inFile)
|
|||||||
|
|
||||||
if (!GetFirstHeader(inFile)) {
|
if (!GetFirstHeader(inFile)) {
|
||||||
if (outError) {
|
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];
|
[newTrack release];
|
||||||
return nil;
|
return nil;
|
||||||
@@ -759,7 +760,8 @@ static bool GetFirstHeader(FILE* inFile)
|
|||||||
if (aacProfileLevel == 2) {
|
if (aacProfileLevel == 2) {
|
||||||
if (profile > MP4_MPEG4_AAC_SSR_AUDIO_TYPE) {
|
if (profile > MP4_MPEG4_AAC_SSR_AUDIO_TYPE) {
|
||||||
if (outError) {
|
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];
|
[newTrack release];
|
||||||
return nil;
|
return nil;
|
||||||
@@ -788,7 +790,8 @@ static bool GetFirstHeader(FILE* inFile)
|
|||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (outError) {
|
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];
|
[newTrack release];
|
||||||
return nil;
|
return nil;
|
||||||
|
|||||||
@@ -250,7 +250,7 @@
|
|||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
if (outError != NULL)
|
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,
|
nil,
|
||||||
120);
|
120);
|
||||||
|
|
||||||
@@ -287,7 +287,9 @@
|
|||||||
NSArray *lineFields = csvData[i];
|
NSArray *lineFields = csvData[i];
|
||||||
if (lineFields.count != 2 || [lineFields[0] integerValue] != i + 1) {
|
if (lineFields.count != 2 || [lineFields[0] integerValue] != i + 1) {
|
||||||
if (NULL != outError)
|
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;
|
return NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -298,7 +300,9 @@
|
|||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
if (NULL != outError)
|
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;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+22
-12
@@ -162,7 +162,8 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
|
|||||||
if (![self startReading]) {
|
if (![self startReading]) {
|
||||||
|
|
||||||
if (error) {
|
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];
|
[_logger writeErrorToLog:*error];
|
||||||
}
|
}
|
||||||
return nil;
|
return nil;
|
||||||
@@ -177,7 +178,8 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
|
|||||||
[self stopReading];
|
[self stopReading];
|
||||||
|
|
||||||
if (error) {
|
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];
|
[_logger writeErrorToLog:*error];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +192,8 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
|
|||||||
[self stopReading];
|
[self stopReading];
|
||||||
|
|
||||||
if (error) {
|
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];
|
[_logger writeErrorToLog:*error];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -622,7 +625,8 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
|
|||||||
|
|
||||||
if (!url) {
|
if (!url) {
|
||||||
if (outError) {
|
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];
|
[_logger writeErrorToLog:*outError];
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
@@ -632,7 +636,8 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
|
|||||||
NSURL *sourceURL = track.URL.filePathURL;
|
NSURL *sourceURL = track.URL.filePathURL;
|
||||||
if ([sourceURL isEqualTo:url]) {
|
if ([sourceURL isEqualTo:url]) {
|
||||||
if (outError) {
|
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];
|
[_logger writeErrorToLog:*outError];
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
@@ -672,7 +677,8 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
|
|||||||
else {
|
else {
|
||||||
success = NO;
|
success = NO;
|
||||||
if (outError) {
|
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];
|
[_logger writeErrorToLog:*outError];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -725,7 +731,8 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
|
|||||||
} else {
|
} else {
|
||||||
success = NO;
|
success = NO;
|
||||||
if (outError) {
|
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];
|
[_logger writeErrorToLog:*outError];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -739,7 +746,9 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
|
|||||||
// Open the mp4 file
|
// Open the mp4 file
|
||||||
if (![self startWriting]) {
|
if (![self startWriting]) {
|
||||||
if (outError) {
|
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];
|
[_logger writeErrorToLog:*outError];
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
@@ -773,7 +782,8 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
|
|||||||
track.importer = fileImporter;
|
track.importer = fileImporter;
|
||||||
} else {
|
} else {
|
||||||
if (outError) {
|
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];
|
[_logger writeErrorToLog:error];
|
||||||
if (outError) { *outError = error; }
|
if (outError) { *outError = error; }
|
||||||
}
|
}
|
||||||
@@ -789,7 +799,7 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
|
|||||||
} else {
|
} else {
|
||||||
// We don't know how to handle this type of track.
|
// We don't know how to handle this type of track.
|
||||||
// Just drop it.
|
// 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],
|
[NSString stringWithFormat:@"%@, %u, has not been muxed.", track.name, (unsigned int)track.format],
|
||||||
201);
|
201);
|
||||||
|
|
||||||
@@ -833,8 +843,8 @@ static void logCallback(MP4LogLevel loglevel, const char *fmt, va_list ap) {
|
|||||||
// Close the mp4 file handle
|
// Close the mp4 file handle
|
||||||
if (![self stopWriting]) {
|
if (![self stopWriting]) {
|
||||||
if (outError) {
|
if (outError) {
|
||||||
*outError = MP42Error(@"File excedes 4 GB.",
|
*outError = MP42Error(MP42LocalizedString(@"File excedes 4 GB.", @"error message"),
|
||||||
@"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.",
|
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);
|
102);
|
||||||
[_logger writeErrorToLog:*outError];
|
[_logger writeErrorToLog:*outError];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,7 +170,8 @@ static int readMkvPacket(struct StdIoStream *ioStream, TrackInfo *trackInfo, ui
|
|||||||
|
|
||||||
if (!_matroskaFile) {
|
if (!_matroskaFile) {
|
||||||
if (outError) {
|
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];
|
[self release];
|
||||||
|
|||||||
@@ -11,6 +11,10 @@
|
|||||||
#import "MP42Utilities.h"
|
#import "MP42Utilities.h"
|
||||||
#include "mp4v2.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
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@@ -22,7 +26,7 @@ typedef enum { TRACK_DISABLED = 0x0,
|
|||||||
TRACK_IN_POSTER = 0x8
|
TRACK_IN_POSTER = 0x8
|
||||||
} track_header_flags;
|
} 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 MP4SetTrackEnabled(MP4FileHandle fileHandle, MP4TrackId trackId);
|
||||||
int MP4SetTrackDisabled(MP4FileHandle fileHandle, MP4TrackId trackId);
|
int MP4SetTrackDisabled(MP4FileHandle fileHandle, MP4TrackId trackId);
|
||||||
|
|||||||
@@ -103,7 +103,8 @@
|
|||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
if (outError) {
|
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];
|
[newTrack release];
|
||||||
|
|||||||
@@ -79,7 +79,7 @@
|
|||||||
{
|
{
|
||||||
if (!fileHandle || !self.trackId) {
|
if (!fileHandle || !self.trackId) {
|
||||||
if ( outError != NULL) {
|
if ( outError != NULL) {
|
||||||
*outError = MP42Error(@"Error: couldn't mux subtitle track",
|
*outError = MP42Error(MP42LocalizedString(@"Error: couldn't mux subtitle track", @"error message"),
|
||||||
nil,
|
nil,
|
||||||
120);
|
120);
|
||||||
return NO;
|
return NO;
|
||||||
|
|||||||
+1
-1
@@ -196,7 +196,7 @@
|
|||||||
|
|
||||||
if (!fileHandle || !_trackId) {
|
if (!fileHandle || !_trackId) {
|
||||||
if ( outError != NULL) {
|
if ( outError != NULL) {
|
||||||
*outError = MP42Error(@"Failed to modify track",
|
*outError = MP42Error(MP42LocalizedString(@"Failed to modify track", @"error message"),
|
||||||
nil,
|
nil,
|
||||||
120);
|
120);
|
||||||
return NO;
|
return NO;
|
||||||
|
|||||||
@@ -252,7 +252,8 @@ static NSArray<SBVobSubTrack *> * LoadVobSubSubtitles(NSURL *theDirectory, NSStr
|
|||||||
|
|
||||||
if (!self.tracks.count) {
|
if (!self.tracks.count) {
|
||||||
if (outError) {
|
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];
|
[self release];
|
||||||
|
|||||||
Reference in new issue
Block a user