diff --git a/ChangeLog b/ChangeLog index 07859f6a5..9fc7ceb1e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2011-02-15 Richard Frith-Macdonald + + * Source/GSLocale.m: + * Source/NSTimeZone.m: + * Source/NSBundle.m: + * Source/NSProcessInfo.m: + * Source/NSUndoManager.m: + * Source/NSFileHandle.m: + * Source/NSSortDescriptor.m: + * Source/NSFileManager.m: + * Source/common.h: + * Source/externs.m: + * Source/NSException.m: + * Source/NSString.m: + * Source/Additions/Unicode.m: + * Source/Additions/GSXML.m: + * Source/NSLocale.m: + * Source/NSTask.m: + As suggested by Wolfgang, change the _() macro for localization when + used inside base to use the base library bundle rather than the main + bundle. + 2011-02-14 Stefan Bidigaray * Headers/Foundation/NSDateFormatter.m: diff --git a/Source/Additions/GSXML.m b/Source/Additions/GSXML.m index 9d8ed452b..f44602320 100644 --- a/Source/Additions/GSXML.m +++ b/Source/Additions/GSXML.m @@ -54,7 +54,6 @@ #import "GNUstepBase/GSMime.h" #import "GNUstepBase/GSXML.h" #import "Foundation/NSArray.h" -#import "Foundation/NSBundle.h" #import "Foundation/NSCalendarDate.h" #import "Foundation/NSCharacterSet.h" #import "Foundation/NSData.h" diff --git a/Source/Additions/Unicode.m b/Source/Additions/Unicode.m index 184b7e4e4..968fd7dae 100644 --- a/Source/Additions/Unicode.m +++ b/Source/Additions/Unicode.m @@ -31,7 +31,6 @@ #import "common.h" #if !defined(NeXT_Foundation_LIBRARY) #import "Foundation/NSArray.h" -#import "Foundation/NSBundle.h" #import "Foundation/NSDictionary.h" #import "Foundation/NSError.h" #import "Foundation/NSException.h" diff --git a/Source/GSLocale.m b/Source/GSLocale.m index 9a160646f..5d70c7cde 100644 --- a/Source/GSLocale.m +++ b/Source/GSLocale.m @@ -35,7 +35,6 @@ #include #endif #import "Foundation/NSUserDefaults.h" -#import "Foundation/NSBundle.h" #import "GSPrivate.h" diff --git a/Source/NSBundle.m b/Source/NSBundle.m index 4579f8a8e..dea1b96d1 100644 --- a/Source/NSBundle.m +++ b/Source/NSBundle.m @@ -54,6 +54,11 @@ #import "GSPrivate.h" +/* Constants */ +NSString * const NSBundleDidLoadNotification = @"NSBundleDidLoadNotification"; +NSString * const NSShowNonLocalizedStrings = @"NSShowNonLocalizedStrings"; +NSString * const NSLoadedClasses = @"NSLoadedClasses"; + #ifdef HAVE_UNISTD_H #include #endif @@ -2102,11 +2107,11 @@ IF_NO_GC( if (tableContent != nil) { NSWarnMLog (@"Localisation file %@ not in portable encoding" - @" so I'm using the default encoding for the current" - @" system, which may not display messages correctly.\n" - @"The file should be ASCII (using \\U escapes for unicode" - @" characters) or Unicode (UTF16 or UTF8) with a leading " - @"byte-order-marker.\n", tablePath); + @" so I'm using the default encoding for the current" + @" system, which may not display messages correctly.\n" + @"The file should be ASCII (using \\U escapes for unicode" + @" characters) or Unicode (UTF16 or UTF8) with a leading " + @"byte-order-marker.\n", tablePath); } } if (tableContent == nil) diff --git a/Source/NSException.m b/Source/NSException.m index adb3179a3..ee1f63292 100644 --- a/Source/NSException.m +++ b/Source/NSException.m @@ -28,7 +28,6 @@ #define EXPOSE_NSException_IVARS 1 #define EXPOSE_NSThread_IVARS 1 #import "GSPrivate.h" -#import "Foundation/NSBundle.h" #import "Foundation/NSEnumerator.h" #import "Foundation/NSException.h" #import "Foundation/NSArray.h" diff --git a/Source/NSFileHandle.m b/Source/NSFileHandle.m index 963179a1b..c0b1dfba2 100644 --- a/Source/NSFileHandle.m +++ b/Source/NSFileHandle.m @@ -30,7 +30,6 @@ #import "Foundation/NSData.h" #import "Foundation/NSFileHandle.h" #import "Foundation/NSPathUtilities.h" -#import "Foundation/NSBundle.h" #import "GNUstepBase/GSFileHandle.h" #import "GNUstepBase/NSObject+GNUstepBase.h" diff --git a/Source/NSFileManager.m b/Source/NSFileManager.m index a1130701d..582bfbaa2 100644 --- a/Source/NSFileManager.m +++ b/Source/NSFileManager.m @@ -47,7 +47,6 @@ #define EXPOSE_NSDirectoryEnumerator_IVARS 1 #import "Foundation/NSArray.h" #import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSBundle.h" #import "Foundation/NSData.h" #import "Foundation/NSDate.h" #import "Foundation/NSDictionary.h" diff --git a/Source/NSLocale.m b/Source/NSLocale.m index 32d01e674..755286093 100644 --- a/Source/NSLocale.m +++ b/Source/NSLocale.m @@ -25,7 +25,6 @@ #import "common.h" #import "Foundation/NSLocale.h" #import "Foundation/NSArray.h" -#import "Foundation/NSBundle.h" #import "Foundation/NSCalendar.h" #import "Foundation/NSCoder.h" #import "Foundation/NSCharacterSet.h" diff --git a/Source/NSProcessInfo.m b/Source/NSProcessInfo.m index aa3b6894b..a787dfb66 100644 --- a/Source/NSProcessInfo.m +++ b/Source/NSProcessInfo.m @@ -103,7 +103,6 @@ #import "GNUstepBase/GSConfig.h" #import "Foundation/NSArray.h" -#import "Foundation/NSBundle.h" #import "Foundation/NSSet.h" #import "Foundation/NSDictionary.h" #import "Foundation/NSDate.h" diff --git a/Source/NSSortDescriptor.m b/Source/NSSortDescriptor.m index f272fdab2..5904f73b5 100644 --- a/Source/NSSortDescriptor.m +++ b/Source/NSSortDescriptor.m @@ -27,7 +27,6 @@ #define EXPOSE_NSSortDescriptor_IVARS 1 #import "Foundation/NSSortDescriptor.h" -#import "Foundation/NSBundle.h" #import "Foundation/NSCoder.h" #import "Foundation/NSException.h" #import "Foundation/NSKeyValueCoding.h" diff --git a/Source/NSString.m b/Source/NSString.m index d1071724f..1ae67d611 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -60,7 +60,6 @@ #import "Foundation/NSRange.h" #import "Foundation/NSException.h" #import "Foundation/NSData.h" -#import "Foundation/NSBundle.h" #import "Foundation/NSURL.h" #import "Foundation/NSMapTable.h" #import "Foundation/NSLock.h" diff --git a/Source/NSTask.m b/Source/NSTask.m index ccad77e6e..7513fc0d3 100644 --- a/Source/NSTask.m +++ b/Source/NSTask.m @@ -28,7 +28,6 @@ #import "common.h" #define EXPOSE_NSTask_IVARS 1 #import "Foundation/NSAutoreleasePool.h" -#import "Foundation/NSBundle.h" #import "Foundation/NSCharacterSet.h" #import "Foundation/NSData.h" #import "Foundation/NSDate.h" diff --git a/Source/NSTimeZone.m b/Source/NSTimeZone.m index a8b0e31ac..b67589f27 100644 --- a/Source/NSTimeZone.m +++ b/Source/NSTimeZone.m @@ -92,7 +92,6 @@ #import "Foundation/NSLock.h" #import "Foundation/NSProcessInfo.h" #import "Foundation/NSUserDefaults.h" -#import "Foundation/NSBundle.h" #import "Foundation/NSMapTable.h" #import "Foundation/NSThread.h" #import "Foundation/NSNotification.h" diff --git a/Source/NSUndoManager.m b/Source/NSUndoManager.m index de21e2878..3e8b807b6 100644 --- a/Source/NSUndoManager.m +++ b/Source/NSUndoManager.m @@ -27,39 +27,12 @@ #import "common.h" #define EXPOSE_NSUndoManager_IVARS 1 #import "Foundation/NSArray.h" -#import "Foundation/NSBundle.h" #import "Foundation/NSNotification.h" #import "Foundation/NSInvocation.h" #import "Foundation/NSException.h" #import "Foundation/NSRunLoop.h" #import "Foundation/NSUndoManager.h" -/* - * Localize a message of the gnustep-base library. - */ -static inline NSString *GSBaseLocalizedString (NSString *key) -{ - static NSBundle *baseBundle = nil; - - if (!baseBundle) - { - /* Create the base bundle we use to localize messages. */ - baseBundle = [NSBundle bundleForLibrary: @"gnustep-base" - version: OBJC_STRINGIFY(GNUSTEP_BASE_MAJOR_VERSION.GNUSTEP_BASE_MINOR_VERSION)]; - RETAIN(baseBundle); - } - - if (baseBundle != nil) - { - return [baseBundle localizedStringForKey: key value: @"" table: nil]; - } - else - { - return key; - } -} - - /* * Private class for grouping undo/redo actions. */ @@ -715,12 +688,11 @@ static inline NSString *GSBaseLocalizedString (NSString *key) { if ([actionName isEqual: @""]) { - return GSBaseLocalizedString(@"Redo"); + return _(@"Redo"); } else { - return [NSString stringWithFormat: - GSBaseLocalizedString(@"Redo %@"), actionName]; + return [NSString stringWithFormat: @"%@ %@", _(@"Redo"), actionName]; } } return actionName; @@ -996,12 +968,11 @@ static inline NSString *GSBaseLocalizedString (NSString *key) { if ([actionName isEqual: @""]) { - return GSBaseLocalizedString(@"Undo"); + return _(@"Undo"); } else { - return [NSString stringWithFormat: - GSBaseLocalizedString(@"Undo %@"), actionName]; + return [NSString stringWithFormat: @"%@ %@", _(@"Undo"), actionName]; } } return actionName; diff --git a/Source/common.h b/Source/common.h index 3b8401bf0..8587c5bc8 100644 --- a/Source/common.h +++ b/Source/common.h @@ -37,6 +37,15 @@ */ #import "Foundation/NSString.h" #import "Foundation/NSDebug.h" +#import "Foundation/NSBundle.h" +#import "GNUstepBase/NSBundle+GNUstepBase.h" + +/* Change localisation macro for use within the base library itsself. + */ +#undef _ +#define _(X) [[NSBundle bundleForLibrary: @"gnustep-base" version: \ + OBJC_STRINGIFY(GNUSTEP_BASE_MAJOR_VERSION.GNUSTEP_BASE_MINOR_VERSION)] \ + localizedStringForKey:(X) value: @"" table: nil] #include #include diff --git a/Source/externs.m b/Source/externs.m index d7ddac7a7..2c0a4d0e0 100644 --- a/Source/externs.m +++ b/Source/externs.m @@ -103,13 +103,6 @@ NSString *const NSIsNotNilTransformerName NSString *const NSUnarchiveFromDataTransformerName = @"NSUnarchiveFromData"; -/* NSBundle */ -NSString *NSBundleDidLoadNotification = @"NSBundleDidLoadNotification"; - -NSString *NSShowNonLocalizedStrings = @"NSShowNonLocalizedStrings"; - -NSString *NSLoadedClasses = @"NSLoadedClasses"; - /* Standard domains */ NSString *NSArgumentDomain = @"NSArgumentDomain"; @@ -245,7 +238,6 @@ GSPrivateBuildStrings() GS_REPLACE_CONSTANT_STRING(GSNetworkNotificationCenterType); GS_REPLACE_CONSTANT_STRING(NSAMPMDesignation); GS_REPLACE_CONSTANT_STRING(NSArgumentDomain); - GS_REPLACE_CONSTANT_STRING(NSBundleDidLoadNotification); GS_REPLACE_CONSTANT_STRING(NSClassDescriptionNeededForClassNotification); GS_REPLACE_CONSTANT_STRING(NSConnectionDidDieNotification); GS_REPLACE_CONSTANT_STRING(NSConnectionDidInitializeNotification); @@ -270,7 +262,6 @@ GSPrivateBuildStrings() GS_REPLACE_CONSTANT_STRING(NSLanguageCode); GS_REPLACE_CONSTANT_STRING(NSLanguageName); GS_REPLACE_CONSTANT_STRING(NSLaterTimeDesignations); - GS_REPLACE_CONSTANT_STRING(NSLoadedClasses); GS_REPLACE_CONSTANT_STRING(GSLocale); GS_REPLACE_CONSTANT_STRING(NSLocalNotificationCenterType); GS_REPLACE_CONSTANT_STRING(NSMonthNameArray); @@ -285,7 +276,6 @@ GSPrivateBuildStrings() GS_REPLACE_CONSTANT_STRING(NSShortMonthNameArray); GS_REPLACE_CONSTANT_STRING(NSShortTimeDateFormatString); GS_REPLACE_CONSTANT_STRING(NSShortWeekDayNameArray); - GS_REPLACE_CONSTANT_STRING(NSShowNonLocalizedStrings); GS_REPLACE_CONSTANT_STRING(NSTaskDidTerminateNotification); GS_REPLACE_CONSTANT_STRING(NSThisDayDesignations); GS_REPLACE_CONSTANT_STRING(NSThousandsSeparator);