Skip to content
This repository was archived by the owner on Jan 16, 2021. It is now read-only.

Define PFLocalizedString, avoiding re-mapping NSLocalizedString macro. #193

Merged
merged 1 commit into from
Nov 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ParseUI/Classes/Cells/PFPurchaseTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ - (void)setState:(PFPurchaseTableViewCellState)state {
{
self.detailTextLabel.numberOfLines = 1;
self.priceLabel.backgroundColor = [UIColor colorWithRed:132.0f/255.0f green:175.0f/255.0f blue:230.0f/255.0f alpha:1.0f];
NSString *downloadingText = NSLocalizedString(@"DOWNLOADING", @"DOWNLOADING");
NSString *downloadingText = PFLocalizedString(@"DOWNLOADING", @"DOWNLOADING");
self.priceLabel.text = [NSString stringWithFormat:@" %@ ", downloadingText];
self.priceLabel.textColor = [UIColor whiteColor];
self.priceLabel.shadowColor = [UIColor blackColor];
Expand All @@ -136,7 +136,7 @@ - (void)setState:(PFPurchaseTableViewCellState)state {
case PFPurchaseTableViewCellStateDownloaded:
{
self.detailTextLabel.numberOfLines = 2;
NSString *installedText = NSLocalizedString(@"INSTALLED", @"INSTALLED");
NSString *installedText = PFLocalizedString(@"INSTALLED", @"INSTALLED");
self.priceLabel.text = [NSString stringWithFormat:@" %@ ", installedText];
self.priceLabel.textColor = [UIColor whiteColor];
self.priceLabel.shadowColor = [UIColor blackColor];
Expand Down
2 changes: 1 addition & 1 deletion ParseUI/Classes/Internal/Extensions/PFUIAlertView.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ + (void)showAlertViewWithTitle:(NSString *)title error:(NSError *)error {
+ (void)showAlertViewWithTitle:(NSString *)title message:(NSString *)message {
[self showAlertViewWithTitle:title
message:message
cancelButtonTitle:NSLocalizedString(@"OK", @"OK")];
cancelButtonTitle:PFLocalizedString(@"OK", @"OK")];
}

+ (void)showAlertViewWithTitle:(NSString *)title
Expand Down
3 changes: 1 addition & 2 deletions ParseUI/Classes/Internal/PFLocalization.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
#ifndef ParseUI_PFLocalization_h
#define ParseUI_PFLocalization_h

#undef NSLocalizedString
#define NSLocalizedString(key, comment) \
#define PFLocalizedString(key, comment) \
[[NSBundle bundleForClass:[self class]] localizedStringForKey:key value:nil table:@"ParseUI"]

#endif
2 changes: 1 addition & 1 deletion ParseUI/Classes/Internal/Views/PFLoadingView.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ - (instancetype)initWithFrame:(CGRect)frame {
[self addSubview:_activityIndicator];

_loadingLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_loadingLabel.text = NSLocalizedString(@"Loading...", @"Loading message of PFQueryTableViewController");
_loadingLabel.text = PFLocalizedString(@"Loading...", @"Loading message of PFQueryTableViewController");
_loadingLabel.backgroundColor = [UIColor clearColor];
_loadingLabel.shadowOffset = CGSizeMake(0.0f, 1.0f);
_loadingLabel.shadowColor = [UIColor whiteColor];
Expand Down
20 changes: 10 additions & 10 deletions ParseUI/Classes/LogInViewController/PFLogInView.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ @implementation PFLogInView
+ (PFActionButtonConfiguration *)_defaultSignUpButtonConfiguration {
PFActionButtonConfiguration *configuration = [[PFActionButtonConfiguration alloc] initWithBackgroundImageColor:[PFColor signupButtonBackgroundColor]
image:nil];
NSString *title = NSLocalizedString(@"Sign Up", @"Sign Up");
NSString *title = PFLocalizedString(@"Sign Up", @"Sign Up");
[configuration setTitle:title forButtonStyle:PFActionButtonStyleNormal];
[configuration setTitle:title forButtonStyle:PFActionButtonStyleWide];

Expand All @@ -55,9 +55,9 @@ + (PFActionButtonConfiguration *)_defaultFacebookButtonConfiguration {
PFActionButtonConfiguration *configuration = [[PFActionButtonConfiguration alloc] initWithBackgroundImageColor:[PFColor facebookButtonBackgroundColor]
image:[PFImage imageNamed:PFLogInViewDefaultFacebookButtonImageName]];

[configuration setTitle:NSLocalizedString(@"Facebook", @"Facebook")
[configuration setTitle:PFLocalizedString(@"Facebook", @"Facebook")
forButtonStyle:PFActionButtonStyleNormal];
[configuration setTitle:NSLocalizedString(@"Log In with Facebook", @"Log In with Facebook")
[configuration setTitle:PFLocalizedString(@"Log In with Facebook", @"Log In with Facebook")

forButtonStyle:PFActionButtonStyleWide];

Expand All @@ -68,9 +68,9 @@ + (PFActionButtonConfiguration *)_defaultTwitterButtonConfiguration {
PFActionButtonConfiguration *configuration = [[PFActionButtonConfiguration alloc] initWithBackgroundImageColor:[PFColor twitterButtonBackgroundColor]
image:[PFImage imageNamed:PFLogInViewDefaultTwitterButtonImageName]];

[configuration setTitle:NSLocalizedString(@"Twitter", @"Twitter")
[configuration setTitle:PFLocalizedString(@"Twitter", @"Twitter")
forButtonStyle:PFActionButtonStyleNormal];
[configuration setTitle:NSLocalizedString(@"Log In with Twitter", @"Log In with Twitter")
[configuration setTitle:PFLocalizedString(@"Log In with Twitter", @"Log In with Twitter")

forButtonStyle:PFActionButtonStyleWide];

Expand Down Expand Up @@ -131,7 +131,7 @@ - (void)_updateAllFields {
if (!_passwordField) {
_passwordField = [[PFTextField alloc] initWithFrame:CGRectZero
separatorStyle:PFTextFieldSeparatorStyleBottom];
_passwordField.placeholder = NSLocalizedString(@"Password", @"Password");
_passwordField.placeholder = PFLocalizedString(@"Password", @"Password");
_passwordField.secureTextEntry = YES;
_passwordField.autocorrectionType = UITextAutocorrectionTypeNo;
_passwordField.autocapitalizationType = UITextAutocapitalizationTypeNone;
Expand Down Expand Up @@ -160,7 +160,7 @@ - (void)_updateAllFields {
if (_fields & PFLogInFieldsPasswordForgotten) {
if (!_passwordForgottenButton) {
_passwordForgottenButton = [[PFTextButton alloc] initWithFrame:CGRectZero];
[_passwordForgottenButton setTitle:NSLocalizedString(@"Forgot Password?", "Forgot Password?")
[_passwordForgottenButton setTitle:PFLocalizedString(@"Forgot Password?", "Forgot Password?")
forState:UIControlStateNormal];
[self addSubview:_passwordForgottenButton];
}
Expand All @@ -172,7 +172,7 @@ - (void)_updateAllFields {
if (_fields & PFLogInFieldsLogInButton) {
if (!_logInButton) {
_logInButton = [[PFPrimaryButton alloc] initWithBackgroundImageColor:[PFColor loginButtonBackgroundColor]];
[_logInButton setTitle:NSLocalizedString(@"Log In", @"Log In") forState:UIControlStateNormal];
[_logInButton setTitle:PFLocalizedString(@"Log In", @"Log In") forState:UIControlStateNormal];
[self addSubview:_logInButton];
}
} else {
Expand Down Expand Up @@ -475,10 +475,10 @@ - (void)_updateUsernameFieldStyle {
NSString *usernamePlaceholder = nil;
if (!_emailAsUsername) {
keyboardType = UIKeyboardTypeDefault;
usernamePlaceholder = NSLocalizedString(@"Username", @"Username");
usernamePlaceholder = PFLocalizedString(@"Username", @"Username");
} else {
keyboardType = UIKeyboardTypeEmailAddress;
usernamePlaceholder = NSLocalizedString(@"Email", @"Email");
usernamePlaceholder = PFLocalizedString(@"Email", @"Email");
}

_usernameField.placeholder = usernamePlaceholder;
Expand Down
24 changes: 12 additions & 12 deletions ParseUI/Classes/LogInViewController/PFLogInViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -289,18 +289,18 @@ - (void)_dismissAction {
}

- (void)_forgotPasswordAction PF_EXTENSION_UNAVAILABLE("") {
NSString *title = NSLocalizedString(@"Reset Password", @"Forgot password request title in PFLogInViewController");
NSString *message = NSLocalizedString(@"Please enter the email address for your account.",
NSString *title = PFLocalizedString(@"Reset Password", @"Forgot password request title in PFLogInViewController");
NSString *message = PFLocalizedString(@"Please enter the email address for your account.",
@"Email request message in PFLogInViewController");
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title
message:message
delegate:self
cancelButtonTitle:NSLocalizedString(@"Cancel", @"Cancel")
otherButtonTitles:NSLocalizedString(@"OK", @"OK"), nil];
cancelButtonTitle:PFLocalizedString(@"Cancel", @"Cancel")
otherButtonTitles:PFLocalizedString(@"OK", @"OK"), nil];
alertView.alertViewStyle = UIAlertViewStylePlainTextInput;

UITextField *textField = [alertView textFieldAtIndex:0];
textField.placeholder = NSLocalizedString(@"Email", @"Email");
textField.placeholder = PFLocalizedString(@"Email", @"Email");
textField.keyboardType = UIKeyboardTypeEmailAddress;
textField.returnKeyType = UIReturnKeyDone;

Expand All @@ -310,15 +310,15 @@ - (void)_forgotPasswordAction PF_EXTENSION_UNAVAILABLE("") {
- (void)_requestPasswordResetWithEmail:(NSString *)email {
[PFUser requestPasswordResetForEmailInBackground:email block:^(BOOL success, NSError *error) {
if (success) {
NSString *title = NSLocalizedString(@"Password Reset",
NSString *title = PFLocalizedString(@"Password Reset",
@"Password reset success alert title in PFLogInViewController.");
NSString *message = [NSString stringWithFormat:NSLocalizedString(@"An email with reset instructions has been sent to '%@'.",
NSString *message = [NSString stringWithFormat:PFLocalizedString(@"An email with reset instructions has been sent to '%@'.",
@"Password reset message in PFLogInViewController"), email];
[PFUIAlertView showAlertViewWithTitle:title
message:message
cancelButtonTitle:NSLocalizedString(@"OK", @"OK")];
cancelButtonTitle:PFLocalizedString(@"OK", @"OK")];
} else {
NSString *title = NSLocalizedString(@"Password Reset Failed",
NSString *title = PFLocalizedString(@"Password Reset Failed",
@"Password reset error alert title in PFLogInViewController.");
[PFUIAlertView showAlertViewWithTitle:title error:error];
}
Expand Down Expand Up @@ -471,12 +471,12 @@ - (void)_loginDidFailWithError:(NSError *)error {
if (_delegateExistingMethods.didFailToLogIn) {
[_delegate logInViewController:self didFailToLogInWithError:error];
} else {
NSString *title = NSLocalizedString(@"Login Failed", @"Login failed alert title in PFLogInViewController");
NSString *title = PFLocalizedString(@"Login Failed", @"Login failed alert title in PFLogInViewController");
NSString *message = nil;
if (error.code == kPFErrorObjectNotFound) {
message = NSLocalizedString(@"The username and password you entered don't match", @"Invalid login credentials alert message in PFLogInViewController");
message = PFLocalizedString(@"The username and password you entered don't match", @"Invalid login credentials alert message in PFLogInViewController");
} else {
message = NSLocalizedString(@"Please try again", @"Generic login failed alert message in PFLogInViewController");
message = PFLocalizedString(@"Please try again", @"Generic login failed alert message in PFLogInViewController");
}
[PFUIAlertView showAlertViewWithTitle:title message:message];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ - (void)objectsDidLoad:(NSError *)error {
} else {
cell.state = PFPurchaseTableViewCellStateNormal;

NSString *title = NSLocalizedString(@"Download Error",
NSString *title = PFLocalizedString(@"Download Error",
@"Download Error");
[PFUIAlertView showAlertViewWithTitle:title error:downloadError];
}
Expand Down Expand Up @@ -174,7 +174,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
PFProduct *product = self.objects[indexPath.row];
[PFPurchase buyProduct:product.productIdentifier block:^(NSError *error) {
if (error) {
NSString *title = NSLocalizedString(@"Purchase Error", @"Purchase Error");
NSString *title = PFLocalizedString(@"Purchase Error", @"Purchase Error");
[PFUIAlertView showAlertViewWithTitle:title error:error];
}
}];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ - (UICollectionReusableView *)collectionViewReusableViewForNextPageAction:(UICol
_currentNextPageView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter
withReuseIdentifier:PFQueryCollectionViewNextPageReusableViewIdentifier
forIndexPath:[self _indexPathForPaginationReusableView]];
_currentNextPageView.textLabel.text = NSLocalizedString(@"Load more...", @"Load more...");
_currentNextPageView.textLabel.text = PFLocalizedString(@"Load more...", @"Load more...");
[_currentNextPageView addTarget:self action:@selector(loadNextPage) forControlEvents:UIControlEventTouchUpInside];
_currentNextPageView.animating = self.loading;
return _currentNextPageView;
Expand Down Expand Up @@ -389,26 +389,26 @@ - (void)_handleDeletionError:(NSError *)error {
[self loadObjects];

NSString *errorMessage = [NSString stringWithFormat:@"%@: \"%@\"",
NSLocalizedString(@"Error occurred during deletion", @"Error occurred during deletion"),
PFLocalizedString(@"Error occurred during deletion", @"Error occurred during deletion"),
error.localizedDescription];

if ([UIAlertController class]) {
UIAlertController *errorController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Error", @"Error")
UIAlertController *errorController = [UIAlertController alertControllerWithTitle:PFLocalizedString(@"Error", @"Error")
message:errorMessage
preferredStyle:UIAlertControllerStyleAlert];

[errorController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK")
[errorController addAction:[UIAlertAction actionWithTitle:PFLocalizedString(@"OK", @"OK")
style:UIAlertActionStyleCancel
handler:nil]];

[self presentViewController:errorController animated:YES completion:nil];
} else {
// Cast to `id` is required for building succesfully for app extensions,
// this code actually never runs in App Extensions, since they are iOS 8.0+, so we are good with just a hack
UIAlertView *alertView = [(id)[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", @"Error")
UIAlertView *alertView = [(id)[UIAlertView alloc] initWithTitle:PFLocalizedString(@"Error", @"Error")
message:errorMessage
delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK", @"OK")
cancelButtonTitle:PFLocalizedString(@"OK", @"OK")
otherButtonTitles:nil];

[alertView show];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ - (PFTableViewCell *)tableView:(UITableView *)otherTableView cellForNextPageAtIn
if (cell == nil) {
cell = [[PFActivityIndicatorTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:cellIdentifier];
cell.textLabel.text = NSLocalizedString(@"Load more...", @"Load more...");
cell.textLabel.text = PFLocalizedString(@"Load more...", @"Load more...");
}

cell.animating = self.loading;
Expand Down Expand Up @@ -517,26 +517,26 @@ - (void)_handleDeletionError:(NSError *)error {
[self loadObjects];

NSString *errorMessage = [NSString stringWithFormat:@"%@: \"%@\"",
NSLocalizedString(@"Error occurred during deletion", @"Error occurred during deletion"),
PFLocalizedString(@"Error occurred during deletion", @"Error occurred during deletion"),
error.localizedDescription];

if ([UIAlertController class]) {
UIAlertController *errorController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Error", @"Error")
UIAlertController *errorController = [UIAlertController alertControllerWithTitle:PFLocalizedString(@"Error", @"Error")
message:errorMessage
preferredStyle:UIAlertControllerStyleAlert];

[errorController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK")
[errorController addAction:[UIAlertAction actionWithTitle:PFLocalizedString(@"OK", @"OK")
style:UIAlertActionStyleCancel
handler:nil]];

[self presentViewController:errorController animated:YES completion:nil];
} else {
// Cast to `id` is required for building succesfully for app extensions,
// this code actually never runs in App Extensions, since they are iOS 8.0+, so we are good with just a hack
UIAlertView *alertView = [(id)[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", @"Error")
UIAlertView *alertView = [(id)[UIAlertView alloc] initWithTitle:PFLocalizedString(@"Error", @"Error")
message:errorMessage
delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK", @"OK")
cancelButtonTitle:PFLocalizedString(@"OK", @"OK")
otherButtonTitles:nil];

[alertView show];
Expand Down
Loading