Skip to content

Commit

Permalink
[Localization] Use NSByteCountFormatter instead of manually formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
kirb committed May 23, 2022
1 parent a04705c commit c33a165
Show file tree
Hide file tree
Showing 47 changed files with 8 additions and 414 deletions.
9 changes: 0 additions & 9 deletions Zebra/Base.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,6 @@
//<Download size> (Installed Size: <installed size>)
"%@ (Installed Size: %@)" = "%@ (Installed Size: %@)";

//Package size in bytes (no deceimal)
"%d bytes" = "%d bytes";
//Package size in Kilobytes (no decimal)
"%d KB" = "%d KB";
//Package size in Kilobytes (with decimal)
"%.2f KB" = "%.2f KB";
//Package size in Megabytes (with decimal)
"%.2f MB" = "%.2f MB";

"Add to Wish List" = "Add to Wish List";
"Remove from Wish List" = "Remove from Wish List";

Expand Down
2 changes: 1 addition & 1 deletion Zebra/Console/ZBConsoleViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ - (void)progressUpdate:(CGFloat)progress forPackage:(ZBPackage *)package {
}
totalProgress /= downloadMap.count;
[self updateProgress:totalProgress];
[self updateProgressText:[NSString stringWithFormat: @"%@: %.1f%% ", NSLocalizedString(@"Downloading", @""), totalProgress * 100]];
[self updateProgressText:[NSString stringWithFormat: @"%@: %.0f%% ", NSLocalizedString(@"Downloading", @""), totalProgress * 100]];
}

- (void)finishedPackageDownload:(ZBPackage *)package withError:(NSError *_Nullable)error {
Expand Down
2 changes: 1 addition & 1 deletion Zebra/Keychain/ZBTokenManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ + (SecAccessControlRef)_biometricAccessControl {
}

+ (NSError *)_errorForOSStatus:(OSStatus)status {
NSString *description = [NSString stringWithFormat:@"Error %i", status];
NSString *description = [NSString stringWithFormat:@"Error %i", (int)status];
if (@available(iOS 11.3, *)) {
description = (NSString *)CFBridgingRelease(SecCopyErrorMessageString(status, nil));
}
Expand Down
12 changes: 2 additions & 10 deletions Zebra/Queue/ZBQueue.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#import "ZBDatabaseManager.h"
#import "ZBDevice.h"
#import "ZBStage.h"
#import "ZBUtils.h"

@interface ZBQueue ()
@property (nonatomic, strong) NSMutableDictionary<NSNumber *, NSMutableArray <ZBPackage *> *> *managedQueue;
Expand Down Expand Up @@ -540,16 +541,7 @@ - (NSString *)downloadSizeForQueue:(ZBQueueType)queueType {
totalDownloadSize += [package downloadSize];
}
if (totalDownloadSize > 0) {
NSString *unit = @"bytes";
if (totalDownloadSize > 1024 * 1024) {
totalDownloadSize /= 1024 * 1024;
unit = @"MB";
}
else if (totalDownloadSize > 1024) {
totalDownloadSize /= 1024;
unit = @"KB";
}
return [NSString stringWithFormat:@"%.2f %@", totalDownloadSize, unit];
return [NSByteCountFormatter stringFromByteCount:totalDownloadSize countStyle:NSByteCountFormatterCountStyleFile];
}

return NULL;
Expand Down
19 changes: 4 additions & 15 deletions Zebra/Tabs/Packages/Helpers/ZBPackage.m
Original file line number Diff line number Diff line change
Expand Up @@ -494,24 +494,13 @@ - (NSString * _Nullable)getField:(NSString *)field {
}

- (NSString *)downloadSizeString {
if (downloadSize <= 0) return NULL;
double size = (double)downloadSize;
if (size > 1024 * 1024) {
return [NSString stringWithFormat:NSLocalizedString(@"%.2f MB", @""), size / 1024 / 1024];
}
if (size > 1024) {
return [NSString stringWithFormat:NSLocalizedString(@"%.2f KB", @""), size / 1024];
}
return [NSString stringWithFormat:NSLocalizedString(@"%d bytes", @""), downloadSize];
if (downloadSize <= 0) return nil;
return [NSByteCountFormatter stringFromByteCount:downloadSize countStyle:NSByteCountFormatterCountStyleFile];
}

- (NSString *)installedSizeString {
if (installedSize <= 0) return NULL;
double size = (double)installedSize;
if (size > 1024) {
return [NSString stringWithFormat:NSLocalizedString(@"%.2f MB", @""), size / 1024];
}
return [NSString stringWithFormat:NSLocalizedString(@"%d KB", @""), installedSize];
if (installedSize <= 0) return nil;
return [NSByteCountFormatter stringFromByteCount:installedSize * 1024 countStyle:NSByteCountFormatterCountStyleFile];
}

- (BOOL)isInstalled:(BOOL)strict {
Expand Down
9 changes: 0 additions & 9 deletions Zebra/ar.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@
//<Download size> (Installed Size: <installed size>)
"%@ (Installed Size: %@)" = "%@ (الحجم المثبت: %@)";

//Package size in bytes (no deceimal)
"%d bytes" = "%d بايت";
//Package size in Kilobytes (no decimal)
"%d KB" = "%d ك.ب.";
//Package size in Kilobytes (with decimal)
"%.2f KB" = "%.2f ك.ب.";
//Package size in Megabytes (with decimal)
"%.2f MB" = "%.2f م.ب.";

"Add to Wish List" = "إضافة إلى قائمة الأمنيات";
"Remove from Wish List" = "إزالة من قائمة الأمنيات";

Expand Down
9 changes: 0 additions & 9 deletions Zebra/bg.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@
//<Download size> (Installed Size: <installed size>)
"%@ (Installed Size: %@)" = "%@ (Инсталирана големина: %@)";

//Package size in bytes (no deceimal)
"%d bytes" = "%d байта";
//Package size in Kilobytes (no decimal)
"%d KB" = "%d КБ";
//Package size in Kilobytes (with decimal)
"%.2f KB" = "%.2f КБ";
//Package size in Megabytes (with decimal)
"%.2f MB" = "%.2f МБ";

"Add to Wish List" = "Добави към списък с желания";
"Remove from Wish List" = "Премахване от списъка с желания";

Expand Down
9 changes: 0 additions & 9 deletions Zebra/cs.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@
//<Download size> (Installed Size: <installed size>)
"%@ (Installed Size: %@)" = "%@ (Nainstalovaná velikost: %@)";

//Package size in bytes (no deceimal)
"%d bytes" = "%d bajtů";
//Package size in Kilobytes (no decimal)
"%d KB" = "%d KB";
//Package size in Kilobytes (with decimal)
"%.2f KB" = "%.2f KB";
//Package size in Megabytes (with decimal)
"%.2f MB" = "%.2f MB";

"Add to Wish List" = "Přidat na Wish List";
"Remove from Wish List" = "Odstranit z Wish Listu";

Expand Down
9 changes: 0 additions & 9 deletions Zebra/da.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@
//<Download size> (Installed Size: <installed size>)
"%@ (Installed Size: %@)" = "%@ (Aktuel Størrelse: %@)";

//Package size in bytes (no deceimal)
"%d bytes" = "%d bytes";
//Package size in Kilobytes (no decimal)
"%d KB" = "%d KB";
//Package size in Kilobytes (with decimal)
"%.2f KB" = "%.2f KB";
//Package size in Megabytes (with decimal)
"%.2f MB" = "%.2f MB";

"Add to Wish List" = "Tilføj til Ønskelisten";
"Remove from Wish List" = "Fjern fra Ønskelisten";

Expand Down
9 changes: 0 additions & 9 deletions Zebra/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@
//<Download size> (Installed Size: <installed size>)
"%@ (Installed Size: %@)" = "%@ (Größe der Installation: %@)";

//Package size in bytes (no deceimal)
"%d bytes" = "%d bytes";
//Package size in Kilobytes (no decimal)
"%d KB" = "%d KB";
//Package size in Kilobytes (with decimal)
"%.2f KB" = "%.2f KB";
//Package size in Megabytes (with decimal)
"%.2f MB" = "%.2f MB";

"Add to Wish List" = "Zur Wunschliste hinzufügen";
"Remove from Wish List" = "Von Wunschliste entfernen";

Expand Down
9 changes: 0 additions & 9 deletions Zebra/el.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@
//<Download size> (Installed Size: <installed size>)
"%@ (Installed Size: %@)" = "%@ (Εγκατεστημένος Χώρος: %@)";

//Package size in bytes (no deceimal)
"%d bytes" = "%d bytes";
//Package size in Kilobytes (no decimal)
"%d KB" = "%d KB";
//Package size in Kilobytes (with decimal)
"%.2f KB" = "%.2f KB";
//Package size in Megabytes (with decimal)
"%.2f MB" = "%.2f MB";

"Add to Wish List" = "Πρόσθεσε στην Λίστα Επιθυμιών";
"Remove from Wish List" = "Αφαίρεσε από την Λίστα Επιθυμιών";

Expand Down
9 changes: 0 additions & 9 deletions Zebra/en-UD.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@
//<Download size> (Installed Size: <installed size>)
"%@ (Installed Size: %@)" = "(%@ :ǝzıS pǝןןɐʇsuI) %@";

//Package size in bytes (no deceimal)
"%d bytes" = "sǝʇʎq %d";
//Package size in Kilobytes (no decimal)
"%d KB" = "qʞ %d";
//Package size in Kilobytes (with decimal)
"%.2f KB" = "qʞ %.2f";
//Package size in Megabytes (with decimal)
"%.2f MB" = "qW %.2f";

"Add to Wish List" = "ʇsı˥ ɥsıM oʇ pp∀";
"Remove from Wish List" = "ʇsı˥ ɥsıM ɯoɹɟ ǝʌoɯǝᴚ";

Expand Down
9 changes: 0 additions & 9 deletions Zebra/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@
//<Download size> (Installed Size: <installed size>)
"%@ (Installed Size: %@)" = "%@ (Tamaño Instalado: %@)";

//Package size in bytes (no deceimal)
"%d bytes" = "%d bytes";
//Package size in Kilobytes (no decimal)
"%d KB" = "%d KB";
//Package size in Kilobytes (with decimal)
"%.2f KB" = "%.2f KB";
//Package size in Megabytes (with decimal)
"%.2f MB" = "%.2f MB";

"Add to Wish List" = "Agregar a la lista de deseos";
"Remove from Wish List" = "Quitar de la lista de deseos";

Expand Down
9 changes: 0 additions & 9 deletions Zebra/fa.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@
//<Download size> (Installed Size: <installed size>)
"%@ (Installed Size: %@)" = "%@ (حجم بعد از نصب: %@)";

//Package size in bytes (no deceimal)
"%d bytes" = "%d بایت";
//Package size in Kilobytes (no decimal)
"%d KB" = "%d کیلوبایت";
//Package size in Kilobytes (with decimal)
"%.2f KB" = "%.2f کیلوبایت";
//Package size in Megabytes (with decimal)
"%.2f MB" = "%.2f مگابایت";

"Add to Wish List" = "اضافه کردن به خرید های آینده";
"Remove from Wish List" = "حذف از خرید های آینده";

Expand Down
9 changes: 0 additions & 9 deletions Zebra/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@
//<Download size> (Installed Size: <installed size>)
"%@ (Installed Size: %@)" = "%@ (Taille installée : %@)";

//Package size in bytes (no deceimal)
"%d bytes" = "%d octets";
//Package size in Kilobytes (no decimal)
"%d KB" = "%d Ko";
//Package size in Kilobytes (with decimal)
"%.2f KB" = "%.2f Ko";
//Package size in Megabytes (with decimal)
"%.2f MB" = "%.2f Mo";

"Add to Wish List" = "Ajouter à la Liste de Souhait";
"Remove from Wish List" = "Supprimer de la Liste de Souhait";

Expand Down
9 changes: 0 additions & 9 deletions Zebra/gl.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@
//<Download size> (Installed Size: <installed size>)
"%@ (Installed Size: %@)" = "%@ (Installed Size: %@)";

//Package size in bytes (no deceimal)
"%d bytes" = "%d bytes";
//Package size in Kilobytes (no decimal)
"%d KB" = "%d KB";
//Package size in Kilobytes (with decimal)
"%.2f KB" = "%.2f KB";
//Package size in Megabytes (with decimal)
"%.2f MB" = "%.2f MB";

"Add to Wish List" = "Add to Wish List";
"Remove from Wish List" = "Remove from Wish List";

Expand Down
9 changes: 0 additions & 9 deletions Zebra/he.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@
//<Download size> (Installed Size: <installed size>)
"%@ (Installed Size: %@)" = "%@ (גודל מותקן: %@)";

//Package size in bytes (no deceimal)
"%d bytes" = "%d בתים";
//Package size in Kilobytes (no decimal)
"%d KB" = "%d ק\"ב";
//Package size in Kilobytes (with decimal)
"%.2f KB" = "%.2f ק\"ב";
//Package size in Megabytes (with decimal)
"%.2f MB" = "%.2f מ\"ב";

"Add to Wish List" = "הוסף לרשימת המשאלות";
"Remove from Wish List" = "הסר מרשימת המשאלות";

Expand Down
9 changes: 0 additions & 9 deletions Zebra/hi-IN.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,6 @@
//<Download size> (Installed Size: <installed size>)
"%@ (Installed Size: %@)" = "%@ (Installed Size: %@)";

//Package size in bytes (no deceimal)
"%d bytes" = "%d bytes";
//Package size in Kilobytes (no decimal)
"%d KB" = "%d KB";
//Package size in Kilobytes (with decimal)
"%.2f KB" = "%.2f KB";
//Package size in Megabytes (with decimal)
"%.2f MB" = "%.2f MB";

"Add to Wish List" = "Add to Wish List";
"Remove from Wish List" = "Remove from Wish List";

Expand Down
9 changes: 0 additions & 9 deletions Zebra/hi.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@
//<Download size> (Installed Size: <installed size>)
"%@ (Installed Size: %@)" = "%@ (स्थापित आकार:%@)";

//Package size in bytes (no deceimal)
"%d bytes" = "%d बाइट्स";
//Package size in Kilobytes (no decimal)
"%d KB" = "%d KB";
//Package size in Kilobytes (with decimal)
"%.2f KB" = "%.2f KB";
//Package size in Megabytes (with decimal)
"%.2f MB" = "%.2f MB";

"Add to Wish List" = "इच्छा सूचि में डालें";
"Remove from Wish List" = "विश लिस्ट से निकालें";

Expand Down
9 changes: 0 additions & 9 deletions Zebra/hr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@
//<Download size> (Installed Size: <installed size>)
"%@ (Installed Size: %@)" = "%@ (Instalirana veličina: %@)";

//Package size in bytes (no deceimal)
"%d bytes" = "%d bytes";
//Package size in Kilobytes (no decimal)
"%d KB" = "%d KB";
//Package size in Kilobytes (with decimal)
"%.2f KB" = "%.2f KB";
//Package size in Megabytes (with decimal)
"%.2f MB" = "%.2f MB";

"Add to Wish List" = "Dodaj na popis želja";
"Remove from Wish List" = "Ukloni s popisa želja";

Expand Down
9 changes: 0 additions & 9 deletions Zebra/hu.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@
//<Download size> (Installed Size: <installed size>)
"%@ (Installed Size: %@)" = "%@ (Telepített méret: %@)";

//Package size in bytes (no deceimal)
"%d bytes" = "%d bájt";
//Package size in Kilobytes (no decimal)
"%d KB" = "%d KB";
//Package size in Kilobytes (with decimal)
"%.2f KB" = "%.2f KB";
//Package size in Megabytes (with decimal)
"%.2f MB" = "%.2f MB";

"Add to Wish List" = "Hozzáadás a kívánságlistához";
"Remove from Wish List" = "Eltávolítás a kívánságlistából";

Expand Down
9 changes: 0 additions & 9 deletions Zebra/id.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@
//<Download size> (Installed Size: <installed size>)
"%@ (Installed Size: %@)" = "%@ (Terpasang Ukuran: %@)";

//Package size in bytes (no deceimal)
"%d bytes" = "%d bytes";
//Package size in Kilobytes (no decimal)
"%d KB" = "%d KB";
//Package size in Kilobytes (with decimal)
"%.2f KB" = "%.2f KB";
//Package size in Megabytes (with decimal)
"%.2f MB" = "%.2f MB";

"Add to Wish List" = "Tambahkan ke Daftar Keinginan";
"Remove from Wish List" = "Hapus dari Daftar Keinginan";

Expand Down
9 changes: 0 additions & 9 deletions Zebra/it.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@
//<Download size> (Installed Size: <installed size>)
"%@ (Installed Size: %@)" = "%@ (Dimensione Installata: %@)";

//Package size in bytes (no deceimal)
"%d bytes" = "%d byte";
//Package size in Kilobytes (no decimal)
"%d KB" = "%d KB";
//Package size in Kilobytes (with decimal)
"%.2f KB" = "%.2f KB";
//Package size in Megabytes (with decimal)
"%.2f MB" = "%.2f MB";

"Add to Wish List" = "Aggiungi alla Lista dei Desideri";
"Remove from Wish List" = "Rimuovi dalla Lista dei Desideri";

Expand Down
9 changes: 0 additions & 9 deletions Zebra/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@
//<Download size> (Installed Size: <installed size>)
"%@ (Installed Size: %@)" = "%@ (インストール済み:%@)";

//Package size in bytes (no deceimal)
"%d bytes" = "%d bytes";
//Package size in Kilobytes (no decimal)
"%d KB" = "%d KB";
//Package size in Kilobytes (with decimal)
"%.2f KB" = "%.2f KB";
//Package size in Megabytes (with decimal)
"%.2f MB" = "%.2f MB";

"Add to Wish List" = "ほしいものリストに追加";
"Remove from Wish List" = "ほしいものリストから削除";

Expand Down
Loading

0 comments on commit c33a165

Please sign in to comment.