• 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
NSUndoManager, NSTextView and exotic localization
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSUndoManager, NSTextView and exotic localization


  • Subject: NSUndoManager, NSTextView and exotic localization
  • From: email@hidden
  • Date: Thu, 22 Jun 2006 16:11:38 +0200 (CEST)
  • Importance: Normal

                          Hello all,

  this mail is about how to localize correctly the standard "Undo (or
Redo) Copy (or Paste, or Edit)" menu item in the MainMenu.nib of a
document-based text editor (say, as in the "Create a text editor in 15
minutes" of the Cocoa documentation) for "exotic" languages with little
or no builtin localization support( I localize my apps for Breton).

  After using undoMenuTitleForUndoActionName (see below) , the result
is only half-satisfying : the menu items are translated correctly only
when they are enabled. When shaded, they return to their default
English form.

  Obviously, I added the localization code at a too superficial layer
of the architecture. Can anyone help me out on this ?


                                                       Ewan

  Relevant parts in my code :

 to localize the "Undo" part, LocalizedUndoManager is a subclass of
NSUndoManager
defined as follows :

  in LocalizedUndoManager.h :

 @interface LocalizedUndoManager : NSUndoManager {}
 @end

  in LocalizedUndoManager.m :
 @implementation LocalizedUndoManager

-(NSString*) redoMenuTitleForUndoActionName:(NSString*) actionName
{
   NSString* redo=NSLocalizedString(@"Redo",@"");
   NSString* newActionName=[[NSBundle mainBundle]
                   localizedStringForKey:actionName
                                   value:actionName
                                   table:@"UndoNames"];
   return [NSString stringWithFormat:@"%@ %@", redo,newActionName];
}


-(NSString*) undoMenuTitleForUndoActionName:(NSString*) actionName
{
   NSString* undo=NSLocalizedString(@"Undo",@"");
   NSString* newActionName=[[NSBundle mainBundle]
                   localizedStringForKey:actionName
                                   value:actionName
                                   table:@"UndoNames"];
   return [NSString stringWithFormat:@"%@ %@", undo,newActionName];
}

@end

 The -init method of class MyDocument contains the two lines

    LocalizedUndoManager* manager=[[LocalizedUndoManager alloc] init];
    [self setUndoManager: manager];

all those ingredients ensure that the "Undo" items will be translated
correctly
when enabled, as long as the developer adds the duly completed
Localized.strings and  UndoNames.Strings file among the resources.


 _______________________________________________
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

  • Prev by Date: Re: How to force an initial column sort with NSTableView and controller?
  • Next by Date: Re: Writing GPS Exif tags
  • Previous by thread: Cocoa Application build fails gives unknown symbol '___dso_handle'
  • Next by thread: Date Format Conversion
  • Index(es):
    • Date
    • Thread