diff --git a/ChangeLog b/ChangeLog index c8121ae93..9f3baca6e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-01-29 Richard Frith-Macdonald + + * Source/NSUserDefaults.m: Try to deal with the case where a language + has been set to the ISO standard name rather than an OpenStep name + by converting to an Openstep name as an alternative lookup key. + 2012-01-26 Richard Frith-Macdonald * Source/NSFileManager.m: Fix copying for large files (issue #35381) diff --git a/Source/NSUserDefaults.m b/Source/NSUserDefaults.m index 16d0176af..4102410f5 100644 --- a/Source/NSUserDefaults.m +++ b/Source/NSUserDefaults.m @@ -947,18 +947,32 @@ newLanguages(NSArray *oldNames) { NSDictionary *dict = nil; NSString *path = nil; - NSEnumerator *pathEnumerator = [paths objectEnumerator]; + NSString *alt; + NSEnumerator *pathEnumerator; + /* The language name could be an ISO language identifier rather + * than an OpenStep name (OSX has moved to using them), so we + * try converting as an alternative key for lookup. + */ + alt = GSLanguageFromLocale(lang); + pathEnumerator = [paths objectEnumerator]; while ((path = [pathEnumerator nextObject]) != nil) { path = [[path stringByAppendingPathComponent: tail] - stringByAppendingPathComponent: lang]; - + stringByAppendingPathComponent: lang]; if ([fm fileExistsAtPath: path]) { - /* Path found! */ - break; + break; /* Path found! */ } + if (nil != alt) + { + path = [[path stringByAppendingPathComponent: tail] + stringByAppendingPathComponent: alt]; + if ([fm fileExistsAtPath: path]) + { + break; /* Path found! */ + } + } } if (path != nil) @@ -989,6 +1003,8 @@ newLanguages(NSArray *oldNames) #endif if (locale != nil) { + NSString *i18n = GSLanguageFromLocale(locale); + /* See if we can get the dictionary from i18n * functions. I don't think that the i18n routines * can handle more than one locale, so we don't try to @@ -996,7 +1012,7 @@ newLanguages(NSArray *oldNames) * if it matches 'lang' ... but tell me if I'm wrong * ... */ - if ([lang isEqualToString: GSLanguageFromLocale (locale)]) + if ([lang isEqual: i18n] || [alt isEqualToString: i18n]) { /* We set added_locale to YES to avoid so that we * won't do this C library locale lookup again