Skip to content

Commit

Permalink
#405: localize Cancel button
Browse files Browse the repository at this point in the history
  • Loading branch information
classilla committed Jun 27, 2018
1 parent 1ee0078 commit 66f5bfc
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion widget/cocoa/nsDatePicker.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "nsReadableUtils.h"
#include "nsNetUtil.h"
#include "nsIComponentManager.h"
#include "nsQueryObject.h"
#include "nsServiceManagerUtils.h"
#include "nsIStringBundle.h"
#include "nsCocoaFeatures.h"
#include "nsCocoaUtils.h"
Expand Down Expand Up @@ -280,6 +282,8 @@ - (void)_addDatePickersToAlert
nsDatePicker::nsDatePicker()
{
mHasDefault = false;
mHasMin = false;
mHasMax = false;
}

nsDatePicker::~nsDatePicker()
Expand Down Expand Up @@ -311,13 +315,28 @@ - (void)_addDatePickersToAlert
nsDatePicker::GetDate()
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
nsCOMPtr<nsIStringBundle> stringBundle;
NSString *cancelString = @"Cancel";
nsXPIDLString intlString;
nsresult rv;

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[formatter setDateFormat:@"yyyy-MM-dd"];

nsCOMPtr<nsIStringBundleService> bundleSvc = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
rv = bundleSvc->CreateBundle("chrome://global/locale/commonDialogs.properties", getter_AddRefs(stringBundle));
if (NS_SUCCEEDED(rv)) {
stringBundle->GetStringFromName(MOZ_UTF16("Cancel"), getter_Copies(intlString));
if (intlString)
cancelString = [NSString stringWithCharacters:reinterpret_cast<const unichar*>(intlString.get())
length:intlString.Length()];
}

NSDoubleDatePicker *alert = [NSDoubleDatePicker
alertWithMessageText:@" "// XXX: localize this eventually
defaultButton:nil // "OK"
alternateButton:nil // "Cancel"
alternateButton:cancelString // "Cancel"
otherButton:nil // nothin'
informativeTextWithFormat:@""];
if (mHasDefault) {
Expand Down

0 comments on commit 66f5bfc

Please sign in to comment.