Bug 563270 - Allow Cocoa embedders to localize the Cocoa print UI on 1.9.2. r=josh, a1.9.2.6=dveditz
authorSmokey Ardisson <alqahira@ardisson.org>
Fri, 25 Jun 2010 14:12:42 -0400
changeset 34378 e4036897f465f5044d26855fda4bc29c67b345a7
parent 34377 cef80124331a4db402337196d4b058a7686588f9
child 34379 a026be4d85e06f6ab4ae6969c518df841a798661
push id1427
push useralqahira@ardisson.org
push dateFri, 25 Jun 2010 18:13:21 +0000
reviewersjosh
bugs563270
milestone1.9.2.6pre
Bug 563270 - Allow Cocoa embedders to localize the Cocoa print UI on 1.9.2. r=josh, a1.9.2.6=dveditz
widget/src/cocoa/nsPrintDialogX.mm
--- a/widget/src/cocoa/nsPrintDialogX.mm
+++ b/widget/src/cocoa/nsPrintDialogX.mm
@@ -301,22 +301,22 @@ static const char sHeaderFooterTags[][4]
 
 - (NSPopUpButton*)headerFooterItemListWithFrame:(NSRect)aRect
                                    selectedItem:(const PRUnichar*)aCurrentString
 {
   NSPopUpButton* list = [[[NSPopUpButton alloc] initWithFrame:aRect pullsDown:NO] autorelease];
   [list setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
   [[list cell] setControlSize:NSSmallControlSize];
   NSArray* items =
-    [NSArray arrayWithObjects:[self localizedString:"--blank--"],
-                              [self localizedString:"Title"],
-                              [self localizedString:"URL"],
-                              [self localizedString:"Date/Time"],
-                              [self localizedString:"Page #"],
-                              [self localizedString:"Page # of #"],
+    [NSArray arrayWithObjects:NSLocalizedString(@"--blank--", nil),
+                              NSLocalizedString(@"Title", nil),
+                              NSLocalizedString(@"URL", nil),
+                              NSLocalizedString(@"Date/Time", nil),
+                              NSLocalizedString(@"Page #", nil),
+                              NSLocalizedString(@"Page # of #", nil),
                               nil];
   [list addItemsWithTitles:items];
 
   NS_ConvertUTF16toUTF8 currentStringUTF8(aCurrentString);
   for (unsigned int i = 0; i < NS_ARRAY_LENGTH(sHeaderFooterTags); i++) {
     if (!strcmp(currentStringUTF8.get(), sHeaderFooterTags[i])) {
       [list selectItemAtIndex:i];
       break;
@@ -326,75 +326,75 @@ static const char sHeaderFooterTags[][4]
   return list;
 }
 
 // Build sections
 
 - (void)addOptionsSection
 {
   // Title
-  [self addLabel:"Options:" withFrame:NSMakeRect(0, 240, 151, 22)];
+  [self addLabel:[NSLocalizedString(@"Options:", nil) UTF8String] withFrame:NSMakeRect(0, 240, 151, 22)];
 
   // "Print Selection Only"
-  mPrintSelectionOnlyCheckbox = [self checkboxWithLabel:"Print Selection Only"
+  mPrintSelectionOnlyCheckbox = [self checkboxWithLabel:[NSLocalizedString(@"Print Selection Only", nil) UTF8String]
                                                andFrame:NSMakeRect(156, 240, 0, 0)];
 
   PRBool canPrintSelection;
   mSettings->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB,
                              &canPrintSelection);
   [mPrintSelectionOnlyCheckbox setEnabled:canPrintSelection];
 
   PRInt16 printRange;
   mSettings->GetPrintRange(&printRange);
   if (printRange == nsIPrintSettings::kRangeSelection) {
     [mPrintSelectionOnlyCheckbox setState:NSOnState];
   }
 
   [self addSubview:mPrintSelectionOnlyCheckbox];
 
   // "Shrink To Fit"
-  mShrinkToFitCheckbox = [self checkboxWithLabel:"Ignore Scaling and Shrink To Fit Page Width"
+  mShrinkToFitCheckbox = [self checkboxWithLabel:[NSLocalizedString(@"Ignore Scaling and Shrink To Fit Page Width", nil) UTF8String]
                                         andFrame:NSMakeRect(156, 218, 0, 0)];
 
   PRBool shrinkToFit;
   mSettings->GetShrinkToFit(&shrinkToFit);
   [mShrinkToFitCheckbox setState:(shrinkToFit ? NSOnState : NSOffState)];
 
   [self addSubview:mShrinkToFitCheckbox];
 }
 
 - (void)addAppearanceSection
 {
   // Title
-  [self addLabel:"Appearance:" withFrame:NSMakeRect(0, 188, 151, 22)];
+  [self addLabel:[NSLocalizedString(@"Appearance:", nil) UTF8String] withFrame:NSMakeRect(0, 188, 151, 22)];
 
   // "Print Background Colors"
-  mPrintBGColorsCheckbox = [self checkboxWithLabel:"Print Background Colors"
+  mPrintBGColorsCheckbox = [self checkboxWithLabel:[NSLocalizedString(@"Print Background Colors", nil) UTF8String]
                                           andFrame:NSMakeRect(156, 188, 0, 0)];
 
   PRBool geckoBool;
   mSettings->GetPrintBGColors(&geckoBool);
   [mPrintBGColorsCheckbox setState:(geckoBool ? NSOnState : NSOffState)];
 
   [self addSubview:mPrintBGColorsCheckbox];
 
   // "Print Background Images"
-  mPrintBGImagesCheckbox = [self checkboxWithLabel:"Print Background Images"
+  mPrintBGImagesCheckbox = [self checkboxWithLabel:[NSLocalizedString(@"Print Background Images", nil) UTF8String]
                                           andFrame:NSMakeRect(156, 166, 0, 0)];
 
   mSettings->GetPrintBGImages(&geckoBool);
   [mPrintBGImagesCheckbox setState:(geckoBool ? NSOnState : NSOffState)];
 
   [self addSubview:mPrintBGImagesCheckbox];
 }
 
 - (void)addFramesSection
 {
   // Title
-  [self addLabel:"Frames:" withFrame:NSMakeRect(0, 124, 151, 22)];
+  [self addLabel:[NSLocalizedString(@"Frames:", nil) UTF8String] withFrame:NSMakeRect(0, 124, 151, 22)];
 
   // Radio matrix
   NSButtonCell *radio = [[NSButtonCell alloc] init];
   [radio setButtonType:NSRadioButton];
   [radio setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
   NSMatrix *matrix = [[NSMatrix alloc] initWithFrame:NSMakeRect(156, 81, 400, 66)
                                                 mode:NSRadioModeMatrix
                                            prototype:(NSCell*)radio
@@ -403,19 +403,19 @@ static const char sHeaderFooterTags[][4]
   [radio release];
   [matrix setCellSize:NSMakeSize(400, 21)];
   [self addSubview:matrix];
   [matrix release];
   NSArray *cellArray = [matrix cells];
   mAsLaidOutRadio = [cellArray objectAtIndex:0];
   mSelectedFrameRadio = [cellArray objectAtIndex:1];
   mSeparateFramesRadio = [cellArray objectAtIndex:2];
-  [mAsLaidOutRadio setTitle:[self localizedString:"As Laid Out on the Screen"]];
-  [mSelectedFrameRadio setTitle:[self localizedString:"The Selected Frame"]];
-  [mSeparateFramesRadio setTitle:[self localizedString:"Each Frame on Separate Pages"]];
+  [mAsLaidOutRadio setTitle:NSLocalizedString(@"As Laid Out on the Screen", nil)];
+  [mSelectedFrameRadio setTitle:NSLocalizedString(@"The Selected Frame", nil)];
+  [mSeparateFramesRadio setTitle:NSLocalizedString(@"Each Frame on Separate Pages", nil)];
 
   // Radio enabled state
   PRInt16 frameUIFlag;
   mSettings->GetHowToEnableFrameUI(&frameUIFlag);
   if (frameUIFlag == nsIPrintSettings::kFrameEnableNone) {
     [mAsLaidOutRadio setEnabled:NO];
     [mSelectedFrameRadio setEnabled:NO];
     [mSeparateFramesRadio setEnabled:NO];
@@ -437,21 +437,21 @@ static const char sHeaderFooterTags[][4]
       [mSeparateFramesRadio setState:NSOnState];
       break;
   }
 }
 
 - (void)addHeaderFooterSection
 {
   // Labels
-  [self addLabel:"Page Headers:" withFrame:NSMakeRect(0, 44, 151, 22)];
-  [self addLabel:"Page Footers:" withFrame:NSMakeRect(0, 0, 151, 22)];
-  [self addCenteredLabel:"Left" withFrame:NSMakeRect(156, 22, 100, 22)];
-  [self addCenteredLabel:"Center" withFrame:NSMakeRect(256, 22, 100, 22)];
-  [self addCenteredLabel:"Right" withFrame:NSMakeRect(356, 22, 100, 22)];
+  [self addLabel:[NSLocalizedString(@"Page Headers:", nil) UTF8String] withFrame:NSMakeRect(0, 44, 151, 22)];
+  [self addLabel:[NSLocalizedString(@"Page Footers:", nil) UTF8String] withFrame:NSMakeRect(0, 0, 151, 22)];
+  [self addCenteredLabel:[NSLocalizedString(@"Left", nil) UTF8String] withFrame:NSMakeRect(156, 22, 100, 22)];
+  [self addCenteredLabel:[NSLocalizedString(@"Center", nil) UTF8String] withFrame:NSMakeRect(256, 22, 100, 22)];
+  [self addCenteredLabel:[NSLocalizedString(@"Right", nil) UTF8String] withFrame:NSMakeRect(356, 22, 100, 22)];
 
   // Lists
   nsXPIDLString sel;
 
   mSettings->GetHeaderStrLeft(getter_Copies(sel));
   mHeaderLeftList = [self headerFooterItemListWithFrame:NSMakeRect(156, 44, 100, 22)
                                            selectedItem:sel];
   [self addSubview:mHeaderLeftList];