Skip to content

Commit

Permalink
#56 Move the localisable string to separated string table
Browse files Browse the repository at this point in the history
  • Loading branch information
1and2papa committed Nov 6, 2014
1 parent b1be9c0 commit 1afc316
Show file tree
Hide file tree
Showing 14 changed files with 154 additions and 48 deletions.
10 changes: 5 additions & 5 deletions CTAssetsPickerController/ALAsset+accessibilityLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ - (NSString *)accessibilityLabel
[accessibilityLabels addObject:[self dateAccessibilityLabel]];

if (!self.defaultRepresentation)
[accessibilityLabels addObject:NSLocalizedString(@"Not available", nil)];
[accessibilityLabels addObject:NSLocalizedStringFromTable(@"Not available", @"CTAssetsPickerController", nil)];

return [accessibilityLabels componentsJoinedByString:@", "];
}
Expand All @@ -55,10 +55,10 @@ - (NSString *)accessibilityLabel
- (NSString *)typeAccessibilityLabel
{
if ([self isVideo]) {
return NSLocalizedString(@"Video", nil);
return NSLocalizedStringFromTable(@"Video", @"CTAssetsPickerController", nil);
}

return NSLocalizedString(@"Photo", nil);
return NSLocalizedStringFromTable(@"Photo", @"CTAssetsPickerController", nil);
}

- (NSString *)durationAccessibilityLabel
Expand All @@ -73,10 +73,10 @@ - (NSString *)orientationAccessibilityLabel
CGSize dimension = self.defaultRepresentation.dimensions;

if (dimension.height >= dimension.width) {
return NSLocalizedString(@"Portrait", nil);
return NSLocalizedStringFromTable(@"Portrait", @"CTAssetsPickerController", nil);
}

return NSLocalizedString(@"Landscape", nil);
return NSLocalizedStringFromTable(@"Landscape", @"CTAssetsPickerController", nil);
}

- (NSString *)dateAccessibilityLabel
Expand Down
2 changes: 1 addition & 1 deletion CTAssetsPickerController/CTAssetScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ - (void)addVideoPlayButton
[button setImage:image forState:UIControlStateNormal];
[button addTarget:self action:@selector(playVideo:) forControlEvents:UIControlEventTouchUpInside];

button.accessibilityLabel = NSLocalizedString(@"Play" , nil);
button.accessibilityLabel = NSLocalizedStringFromTable(@"Play", @"CTAssetsPickerController", nil);
button.translatesAutoresizingMaskIntoConstraints = NO;

self.playButton = button;
Expand Down
2 changes: 1 addition & 1 deletion CTAssetsPickerController/CTAssetsGroupViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ - (NSString *)accessibilityLabel
{
NSString *label = [self.assetsGroup valueForProperty:ALAssetsGroupPropertyName];

return [label stringByAppendingFormat:NSLocalizedString(@"%ld Photos", nil), (long)self.assetsGroup.numberOfAssets];
return [label stringByAppendingFormat:NSLocalizedStringFromTable(@"%ld Photos", @"CTAssetsPickerController", nil), (long)self.assetsGroup.numberOfAssets];
}

@end
6 changes: 3 additions & 3 deletions CTAssetsPickerController/CTAssetsGroupViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ - (void)setupButtons
if (self.picker.showsCancelButton)
{
self.navigationItem.leftBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Cancel", nil)
[[UIBarButtonItem alloc] initWithTitle:NSLocalizedStringFromTable(@"Cancel", @"CTAssetsPickerController", nil)
style:UIBarButtonItemStylePlain
target:self.picker
action:@selector(dismiss:)];
}

self.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Done", nil)
[[UIBarButtonItem alloc] initWithTitle:NSLocalizedStringFromTable(@"Done", @"CTAssetsPickerController", nil)
style:UIBarButtonItemStyleDone
target:self.picker
action:@selector(finishPickingAssets:)];
Expand All @@ -144,7 +144,7 @@ - (void)setupToolbar
- (void)localize
{
if (!self.picker.title)
self.title = NSLocalizedString(@"Photos", nil);
self.title = NSLocalizedStringFromTable(@"Photos", @"CTAssetsPickerController", nil);
else
self.title = self.picker.title;
}
Expand Down
2 changes: 1 addition & 1 deletion CTAssetsPickerController/CTAssetsPageViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ - (BOOL)prefersStatusBarHidden
- (void)setTitleIndex:(NSInteger)index
{
NSInteger count = self.assets.count;
self.title = [NSString stringWithFormat:NSLocalizedString(@"%ld of %ld", nil), index, count];
self.title = [NSString stringWithFormat:NSLocalizedStringFromTable(@"%ld of %ld", @"CTAssetsPickerController", nil), index, count];
}


Expand Down
20 changes: 12 additions & 8 deletions CTAssetsPickerController/CTAssetsPickerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,9 @@ - (NSString *)noAssetsMessage
NSString *format;

if ([self isCameraDeviceAvailable])
format = NSLocalizedString(@"You can take photos and videos using the camera, or sync photos and videos onto your %@\nusing iTunes.", nil);
format = NSLocalizedStringFromTable(@"You can take photos and videos using the camera, or sync photos and videos onto your %@\nusing iTunes.", @"CTAssetsPickerController", nil);
else
format = NSLocalizedString(@"You can sync photos and videos onto your %@ using iTunes.", nil);
format = NSLocalizedStringFromTable(@"You can sync photos and videos onto your %@ using iTunes.", @"CTAssetsPickerController", nil);

return [NSString stringWithFormat:format, self.deviceModel];
}
Expand Down Expand Up @@ -351,11 +351,11 @@ - (UIView *)notAllowedView
UILabel *title =
[self auxiliaryLabelWithFont:[UIFont boldSystemFontOfSize:17.0]
color:[UIColor colorWithRed:129.0/255.0 green:136.0/255.0 blue:148.0/255.0 alpha:1]
text:NSLocalizedString(@"This app does not have access to your photos or videos.", nil)];
text:NSLocalizedStringFromTable(@"This app does not have access to your photos or videos.", @"CTAssetsPickerController", nil)];
UILabel *message =
[self auxiliaryLabelWithFont:[UIFont systemFontOfSize:14.0]
color:[UIColor colorWithRed:129.0/255.0 green:136.0/255.0 blue:148.0/255.0 alpha:1]
text:NSLocalizedString(@"You can enable access in Privacy Settings.", nil)];
text:NSLocalizedStringFromTable(@"You can enable access in Privacy Settings.", @"CTAssetsPickerController", nil)];

UIView *centerView = [self centerViewWithViews:@[padlock, title, message]];

Expand All @@ -370,7 +370,7 @@ - (UIView *)noAssetsView
UILabel *title =
[self auxiliaryLabelWithFont:[UIFont systemFontOfSize:26.0]
color:[UIColor colorWithRed:153.0/255.0 green:153.0/255.0 blue:153.0/255.0 alpha:1]
text:NSLocalizedString(@"No Photos or Videos", nil)];
text:NSLocalizedStringFromTable(@"No Photos or Videos", @"CTAssetsPickerController", nil)];

UILabel *message =
[self auxiliaryLabelWithFont:[UIFont systemFontOfSize:18.0]
Expand Down Expand Up @@ -409,13 +409,17 @@ - (NSString *)toolbarTitle
NSString *format;

if (photoSelected && videoSelected)
format = NSLocalizedString(@"%ld Items Selected", nil);
format = NSLocalizedStringFromTable(@"%ld Items Selected", @"CTAssetsPickerController", nil);

else if (photoSelected)
format = (self.selectedAssets.count > 1) ? NSLocalizedString(@"%ld Photos Selected", nil) : NSLocalizedString(@"%ld Photo Selected", nil);
format = (self.selectedAssets.count > 1) ?
NSLocalizedStringFromTable(@"%ld Photos Selected", @"CTAssetsPickerController", nil) :
NSLocalizedStringFromTable(@"%ld Photo Selected", @"CTAssetsPickerController", nil);

else if (videoSelected)
format = (self.selectedAssets.count > 1) ? NSLocalizedString(@"%ld Videos Selected", nil) : NSLocalizedString(@"%ld Video Selected", nil);
format = (self.selectedAssets.count > 1) ?
NSLocalizedStringFromTable(@"%ld Videos Selected", @"CTAssetsPickerController", nil) :
NSLocalizedStringFromTable(@"%ld Video Selected", @"CTAssetsPickerController", nil);

return [NSString stringWithFormat:format, (long)self.selectedAssets.count];
}
Expand Down
6 changes: 3 additions & 3 deletions CTAssetsPickerController/CTAssetsSupplementaryView.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ - (void)bind:(NSArray *)assets
NSInteger numberOfPhotos = [assets filteredArrayUsingPredicate:[self predicateOfAssetType:ALAssetTypePhoto]].count;

if (numberOfVideos == 0)
self.label.text = [NSString stringWithFormat:NSLocalizedString(@"%ld Photos", nil), (long)numberOfPhotos];
self.label.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"%ld Photos", @"CTAssetsPickerController", nil), (long)numberOfPhotos];
else if (numberOfPhotos == 0)
self.label.text = [NSString stringWithFormat:NSLocalizedString(@"%ld Videos", nil), (long)numberOfVideos];
self.label.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"%ld Videos", @"CTAssetsPickerController", nil), (long)numberOfVideos];
else
self.label.text = [NSString stringWithFormat:NSLocalizedString(@"%ld Photos, %ld Videos", nil), (long)numberOfPhotos, (long)numberOfVideos];
self.label.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"%ld Photos, %ld Videos", @"CTAssetsPickerController", nil), (long)numberOfPhotos, (long)numberOfVideos];
}

- (NSPredicate *)predicateOfAssetType:(NSString *)type
Expand Down
2 changes: 1 addition & 1 deletion CTAssetsPickerController/CTAssetsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ - (void)setupViews
- (void)setupButtons
{
self.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Done", nil)
[[UIBarButtonItem alloc] initWithTitle:NSLocalizedStringFromTable(@"Done", @"CTAssetsPickerController", nil)
style:UIBarButtonItemStyleDone
target:self.picker
action:@selector(finishPickingAssets:)];
Expand Down
12 changes: 9 additions & 3 deletions CTAssetsPickerController/NSDateFormatter+timeIntervalFormatter.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,23 @@ - (NSString *)spellOutStringFromTimeInterval:(NSTimeInterval)timeInterval
if (components.hour > 0)
string = [string stringByAppendingFormat:@"%ld %@",
(long)components.hour,
(components.hour > 1) ? NSLocalizedString(@"hours", nil) : NSLocalizedString(@"hour", nil)];
(components.hour > 1) ?
NSLocalizedStringFromTable(@"hours", @"CTAssetsPickerController", nil) :
NSLocalizedStringFromTable(@"hour", @"CTAssetsPickerController", nil)];

if (components.minute > 0)
string = [string stringByAppendingFormat:@"%ld %@",
(long)components.minute,
(components.minute > 1) ? NSLocalizedString(@"minutes", nil) : NSLocalizedString(@"minute", nil)];
(components.minute > 1) ?
NSLocalizedStringFromTable(@"minutes", @"CTAssetsPickerController", nil) :
NSLocalizedStringFromTable(@"minute", @"CTAssetsPickerController", nil)];

if (components.second > 0)
string = [string stringByAppendingFormat:@"%ld %@",
(long)components.second,
(components.second > 1) ? NSLocalizedString(@"seconds", nil) : NSLocalizedString(@"second", nil)];
(components.second > 1) ?
NSLocalizedStringFromTable(@"seconds", @"CTAssetsPickerController", nil) :
NSLocalizedStringFromTable(@"second", @"CTAssetsPickerController", nil)];

return string;
}
Expand Down
48 changes: 48 additions & 0 deletions CTAssetsPickerController/en.lproj/CTAssetsPickerController.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* Navigation bar buttons */
"Cancel" = "Cancel";
"Done" = "Done";

/* Default title */
"Photos" = "Photos";

/* No. of selected */
"%ld Photo Selected" = "%ld Photo Selected";
"%ld Photos Selected" = "%ld Photos Selected";
"%ld Video Selected" = "%ld Video Selected";
"%ld Videos Selected" = "%ld Videos Selected";
"%ld Items Selected" = "%ld Items Selected";

/* Album's footer */
"%ld Photos" = "%ld Photos";
"%ld Videos" = "%ld Videos";
"%ld Photos, %ld Videos" = "%1$ld Photos, %2$ld Videos";

/* Assets index */
"%ld of %ld" = "%1$ld of %2$ld";

/* Messages if privacy is not granted */
"This app does not have access to your photos or videos." = "This app does not have access to your photos or videos.";
"You can enable access in Privacy Settings." = "You can enable access in Privacy Settings.";

/* Messages if no assets */
"No Photos or Videos" = "No Photos or Videos";

/* The parameter will be replaced by the device model name */
"You can take photos and videos using the camera, or sync photos and videos onto your %@\nusing iTunes." = "You can take photos and videos using the camera, or sync photos and videos onto your %@\nusing iTunes.";
"You can sync photos and videos onto your iPhone using iTunes." = "You can sync photos and videos onto your iPhone using iTunes.";

/* Accessibility labels */
"Photo" = "Photo";
"Video" = "Video";
"Portrait" = "Portrait";
"Landscape" = "Landscape";
"Play" = "Play";
"Not available" = "Not available";

/* Video duration spell out */
"hours" = "hours";
"hour" = "hour";
"minutes" = "minutes";
"minute" = "minute";
"seconds" = "seconds";
"second" = "second";
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* Navigation bar buttons */
"Cancel" = "取消";
"Done" = "完成";

/* Default title */
"Photos" = "照片";

/* No. of selected */
"%ld Photo Selected" = "已選取 %ld 張照片";
"%ld Photos Selected" = "已選取 %ld 張照片";
"%ld Video Selected" = "已選取 %ld 部影片";
"%ld Videos Selected" = "已選取 %ld 部影片";
"%ld Items Selected" = "已選取 %ld 個項目";

/* Album's footer */
"%ld Photos" = "%ld 張照片";
"%ld Videos" = "%ld 部影片";
"%ld Photos, %ld Videos" = "%1$ld 張照片、%2$ld 部影片";

/* Assets index */
"%ld of %ld" = "%1$ld/%2$ld";

/* Messages if privacy is not granted */
"This app does not have access to your photos or videos." = "此 App 無法取用您的照片或影片。";
"You can enable access in Privacy Settings." = "您可以在「隱私權設定」中啟用存取。";

/* Messages if no assets */
"No Photos or Videos" = "沒有照片或影片";

/* The parameter will be replaced by the device model name */
"You can take photos and videos using the camera, or sync photos and videos onto your %@\nusing iTunes." = "您可以用相機拍照錄影或用 iTunes\n將照片和影片同步到 %@。";
"You can sync photos and videos onto your %@ using iTunes." = "您可以使用 iTunes 將照片和影片\n同步到 %@。";

/* Accessibility labels */
"Photo" = "照片";
"Video" = "影片";
"Portrait" = "直向";
"Landscape" = "橫向";
"Play" = "播放";
"Not available" = "無法使用";

/* Video duration spell out */
"hours" = "小時";
"hour" = "小時";
"minutes" = "分";
"minute" = "分";
"seconds" = "秒";
"second" = "秒";
Loading

0 comments on commit 1afc316

Please sign in to comment.