Made the error message localisable.

This commit is contained in:
Damiano Galassi committed 2016-11-23 12:09:15 +01:00
1 parent 384d30d00c
commit 6f31037011
9 files changed
+48 -24

No files matched your search

+6 -3
View File
@@ -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;
+7 -3
View File
@@ -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;
}
+22 -12
View File
@@ -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];
}
+2 -1
View File
@@ -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];
+5 -1
View File
@@ -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);
+2 -1
View File
@@ -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];
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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;
+2 -1
View File
@@ -252,7 +252,8 @@ static NSArray<SBVobSubTrack *> * 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];