Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add localization support #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 9 additions & 4 deletions FacebookImagePicker/OLAlbumViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ @implementation OLAlbumViewController
- (id)init {
NSBundle *currentBundle = [NSBundle bundleForClass:[OLAlbumViewController class]];
if (self = [self initWithNibName:NSStringFromClass([OLAlbumViewController class]) bundle:currentBundle]) {
self.title = @"Photos";
self.title = NSLocalizedStringWithDefaultValue(@"ol.albumview.title", nil, [NSBundle mainBundle], @"Photos", nil);
self.albums = [[NSMutableArray alloc] init];
_shouldDisplayLogoutButton = YES;
}
Expand All @@ -87,7 +87,10 @@ - (id)init {
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(onButtonDoneClicked)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedStringWithDefaultValue(@"ol.albumview.button.done", nil, [NSBundle mainBundle], @"Done", nil)
style:UIBarButtonItemStyleDone
target:self
action:@selector(onButtonDoneClicked)];

if (self.shouldDisplayLogoutButton) {
[self addLogoutButtonAnimated:NO];
Expand Down Expand Up @@ -129,8 +132,10 @@ - (void)setShouldDisplayLogoutButton:(BOOL)shouldDisplayLogoutButton

- (void)addLogoutButtonAnimated:(BOOL)animated
{
[self.navigationItem setLeftBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:@"Logout" style:UIBarButtonItemStylePlain target:self action:@selector(onButtonLogoutClicked)]
animated:animated];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedStringWithDefaultValue(@"ol.albumview.button.logout", nil, [NSBundle mainBundle], @"Logout", nil)
style:UIBarButtonItemStylePlain
target:self
action:@selector(onButtonLogoutClicked)];
}

- (void)loadNextAlbumPage {
Expand Down
18 changes: 13 additions & 5 deletions FacebookImagePicker/OLPhotoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ - (id)initWithAlbum:(OLFacebookAlbum *)album {
- (void)viewDidLoad {
[super viewDidLoad];

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(onButtonDoneClicked)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedStringWithDefaultValue(@"ol.photoview.button.done", nil, [NSBundle mainBundle], @"Done", nil)
style:UIBarButtonItemStyleDone
target:self
action:@selector(onButtonDoneClicked)];

CGFloat itemSize = MIN([UIScreen mainScreen].bounds.size.height, [UIScreen mainScreen].bounds.size.width)/4.0 - 1.0;

Expand Down Expand Up @@ -163,11 +166,16 @@ -(void) updateTitleWithSelectedIndexPaths:(NSArray *)indexPaths{
if (indexPaths.count == 0)
{
self.title = self.album.name;
return;
}

NSString *format = (indexPaths.count > 1) ? NSLocalizedString(@"%ld Photos Selected", nil) : NSLocalizedString(@"%ld Photo Selected", nil);
self.title = [NSString stringWithFormat:format, (unsigned long)indexPaths.count];
else if (indexPaths.count == 1)
{
self.title = NSLocalizedStringWithDefaultValue(@"ol.photoview.1photoselected", nil, [NSBundle mainBundle], @"1 Photo Selected", nil);
}
else
{
self.title = [NSLocalizedStringWithDefaultValue(@"ol.photoview.nbphotoselected", nil, [NSBundle mainBundle], @"##count## Photos Selected", nil)
stringByReplacingOccurrencesOfString:@"##count##" withString:[NSString stringWithFormat:@"%ld", (unsigned long)indexPaths.count]];
}
}

#pragma mark - UICollectionViewDataSource methods
Expand Down