• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: "untitled" vs "Untitled" (code correction)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "untitled" vs "Untitled" (code correction)


  • Subject: Re: "untitled" vs "Untitled" (code correction)
  • From: m <email@hidden>
  • Date: Mon, 11 Jul 2005 18:00:06 -0700

For the archives:

I had posted an override for NSDocument's displayName method that produces HIG compliant results for untitled documents. It's been pointed out to me that all nouns are capitalized in German (and only German apparently), despite efforts at reform <http:// en.wikipedia.org/wiki/German_spelling_reform>, so I modified the code to account for this.

I make no claim that it will produce universally correct results, but for localizations that are available in AppKit (Danish, Dutch, English, Finnish, French, German, Italian, Japanese, Korean, Norwegian, Portuguese, Spanish, Swedish, and Chinese), it appears to work fine.



- (NSString *)displayName
{
     NSString* displayName = [super displayName];

     // Determine if this document was never saved.
     // We do this by checking if the document has a file path. This is
     // complicated (slightly) by the fact that NSDocument's fileURL
method
     // is new in Tiger, and NSDocument's filePath is dperectaed in
Tiger.

     BOOL neverSaved = NO;
     if ([self methodForSelector:@selector(fileURL)])
     {
         neverSaved = [self fileURL] == nil;
     }
     else
     {
         neverSaved = [self fileName] == nil;
     }

if (neverSaved)
{
// Special case for German.
// German is the only language in the world that capitalizes
// all nouns, so our strategy of lowercasing would
produce the
// wrong result.


         NSDictionary* userDefaults = [[NSUserDefaults
standardUserDefaults] dictionaryRepresentation];
         NSArray* myLocalizations = [[NSBundle mainBundle]
localizations];
         NSArray* preferredLocalizations = [NSBundle
preferredLocalizationsFromArray:myLocalizations forPreferences:
[userDefaults objectForKey:@"NSLanguages"]];

         NSString* currentLanguage = [preferredLocalizations
objectAtIndex:0];

         if (![currentLanguage isEqualTo:@"German"])
         {
             // Lowercase the displayName so that, for example,
             // "Untitled 4" becomes "untitled 4".
             displayName = [displayName lowercaseString];
         }
     }

     return displayName;
}


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: "untitled" vs "Untitled" (code correction)
      • From: Andreas Mayer <email@hidden>
References: 
 >"untitled" vs "Untitled" (From: David Catmull <email@hidden>)
 >Re: "untitled" vs "Untitled" (From: Ali Ozer <email@hidden>)
 >Re: "untitled" vs "Untitled" (From: "Brian K." <email@hidden>)
 >Re: "untitled" vs "Untitled" (From: Ali Ozer <email@hidden>)
 >Re: "untitled" vs "Untitled" (From: m <email@hidden>)
 >Re: "untitled" vs "Untitled" (From: "Brian K." <email@hidden>)
 >Re: "untitled" vs "Untitled" (From: Ali Ozer <email@hidden>)
 >Re: "untitled" vs "Untitled" (From: m <email@hidden>)
 >[Moderator] Re: "untitled" vs "Untitled" (From: mmalcolm crawford <email@hidden>)
 >Re: "untitled" vs "Untitled" (From: m <email@hidden>)

  • Prev by Date: Re: Why does this leak memory?
  • Next by Date: Re: Why does this leak memory?
  • Previous by thread: Re: "untitled" vs "Untitled"
  • Next by thread: Re: "untitled" vs "Untitled" (code correction)
  • Index(es):
    • Date
    • Thread