Commit 810bd94c authored by Eugene But's avatar Eugene But Committed by Commit Bot

Localize New Download Manager strings.

Reused existing strings where possible added new strings to grit file
for translation.

Bug: 805533
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I0d38ddfe0ccec27c9c3f28cb04e9717b983d650c
Reviewed-on: https://chromium-review.googlesource.com/935447
Commit-Queue: Eugene But <eugenebut@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539147}
parent 0cf2a199
...@@ -579,9 +579,27 @@ locale. The strings in this file are specific to iOS. ...@@ -579,9 +579,27 @@ locale. The strings in this file are specific to iOS.
<message name="IDS_IOS_DOWNLOAD_MANAGER_DOWNLOAD_FAILED" desc="Label displaying that downloading a file was unsuccessful. [Length: 25em] [iOS only]"> <message name="IDS_IOS_DOWNLOAD_MANAGER_DOWNLOAD_FAILED" desc="Label displaying that downloading a file was unsuccessful. [Length: 25em] [iOS only]">
Download failed. Download failed.
</message> </message>
<message name="IDS_IOS_DOWNLOAD_MANAGER_COULDNT_DOWNLOAD" desc="Label displaying that downloading a file was unsuccessful. [Length: 25em] [iOS only]">
Couldn't Download
</message>
<message name="IDS_IOS_DOWNLOAD_MANAGER_INSTALL_GOOGLE_DRIVE" desc="Button to install the Google Drive app. [Length: 25em] [iOS only]"> <message name="IDS_IOS_DOWNLOAD_MANAGER_INSTALL_GOOGLE_DRIVE" desc="Button to install the Google Drive app. [Length: 25em] [iOS only]">
Install Google Drive Install Google Drive
</message> </message>
<message name="IDS_IOS_DOWNLOAD_MANAGER_INSTALL" desc="Button to install the Google Drive app. [Length: 25em] [iOS only]">
Install
</message>
<message name="IDS_IOS_DOWNLOAD_MANAGER_CANCEL_CONFIRMATION" desc="Alert title to confirm download cancellation [Length: 30em] [iOS only]">
Cancel Download?
</message>
<message name="IDS_IOS_DOWNLOAD_MANAGER_REPLACE_CONFIRMATION" desc="Alert title to confirm download old download replacement [Length: 30em] [iOS only]">
Start New Download?
</message>
<message name="IDS_IOS_DOWNLOAD_MANAGER_REPLACE_CONFIRMATION_MESSAGE" desc="Alert message to confirm download old download replacement [Length: 100em] [iOS only]">
This will stop all progress for your current download.
</message>
<message name="IDS_IOS_DOWNLOAD_MANAGER_DOWNLOADING_ELIPSIS" desc="Label for the file being downloaded. [Length: 25em] [iOS only]">
Downloading… <ph name="FILE_SIZE">$1<ex>456KB</ex></ph>
</message>
<message name="IDS_IOS_DOWNLOAD_MANAGER_NO_APP_MESSAGE" desc="Message displayed in dialog informing user that no application on the phone can open the downloaded file. [Length: 50em] [iOS only]"> <message name="IDS_IOS_DOWNLOAD_MANAGER_NO_APP_MESSAGE" desc="Message displayed in dialog informing user that no application on the phone can open the downloaded file. [Length: 50em] [iOS only]">
No application on this device can open the file. No application on this device can open the file.
</message> </message>
...@@ -591,6 +609,9 @@ locale. The strings in this file are specific to iOS. ...@@ -591,6 +609,9 @@ locale. The strings in this file are specific to iOS.
<message name="IDS_IOS_DOWNLOAD_MANAGER_RETRY_DOWNLOAD" desc="Button to retry downloading a file once a previous attempt to download the file failed. [Length: 25em] [iOS only]"> <message name="IDS_IOS_DOWNLOAD_MANAGER_RETRY_DOWNLOAD" desc="Button to retry downloading a file once a previous attempt to download the file failed. [Length: 25em] [iOS only]">
Retry Download Retry Download
</message> </message>
<message name="IDS_IOS_DOWNLOAD_MANAGER_TRY_AGAIN" desc="Button to retry downloading a file once a previous attempt to download the file failed. [Length: 25em] [iOS only]">
Try Again
</message>
<message name="IDS_IOS_DOWNLOAD_MANAGER_TIME_LEFT" desc="Label displaying the number of minutes remaining for the download. [Length: 7em] [iOS only]"> <message name="IDS_IOS_DOWNLOAD_MANAGER_TIME_LEFT" desc="Label displaying the number of minutes remaining for the download. [Length: 7em] [iOS only]">
<ph name="MINUTES">$1<ex>3</ex></ph> min <ph name="MINUTES">$1<ex>3</ex></ph> min
</message> </message>
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#import "ios/chrome/browser/ui/download/download_manager_view_controller.h" #import "ios/chrome/browser/ui/download/download_manager_view_controller.h"
#import "ios/chrome/browser/ui/presenters/contained_presenter.h" #import "ios/chrome/browser/ui/presenters/contained_presenter.h"
#import "ios/chrome/browser/ui/presenters/contained_presenter_delegate.h" #import "ios/chrome/browser/ui/presenters/contained_presenter_delegate.h"
#include "ios/chrome/grit/ios_strings.h"
#import "ios/web/public/download/download_task.h" #import "ios/web/public/download/download_task.h"
#include "net/url_request/url_fetcher_response_writer.h" #include "net/url_request/url_fetcher_response_writer.h"
#include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
...@@ -87,10 +88,12 @@ ...@@ -87,10 +88,12 @@
- (void)downloadManagerTabHelper:(nonnull DownloadManagerTabHelper*)tabHelper - (void)downloadManagerTabHelper:(nonnull DownloadManagerTabHelper*)tabHelper
decidePolicyForDownload:(nonnull web::DownloadTask*)download decidePolicyForDownload:(nonnull web::DownloadTask*)download
completionHandler:(nonnull void (^)(NewDownloadPolicy))handler { completionHandler:(nonnull void (^)(NewDownloadPolicy))handler {
// TODO(crbug.com/805533): Localize those strings. NSString* title =
NSString* message = @"This will stop all progress for your current download."; l10n_util::GetNSString(IDS_IOS_DOWNLOAD_MANAGER_REPLACE_CONFIRMATION);
NSString* message = l10n_util::GetNSString(
IDS_IOS_DOWNLOAD_MANAGER_REPLACE_CONFIRMATION_MESSAGE);
__weak DownloadManagerCoordinator* weakSelf = self; __weak DownloadManagerCoordinator* weakSelf = self;
[self runConfirmationDialogWithTitle:@"Start New Download?" [self runConfirmationDialogWithTitle:title
message:message message:message
completionHandler:^(BOOL confirmed) { completionHandler:^(BOOL confirmed) {
DownloadManagerCoordinator* strongSelf = weakSelf; DownloadManagerCoordinator* strongSelf = weakSelf;
...@@ -137,8 +140,9 @@ ...@@ -137,8 +140,9 @@
} }
__weak DownloadManagerCoordinator* weakSelf = self; __weak DownloadManagerCoordinator* weakSelf = self;
// TODO(crbug.com/805533): Localize this string. NSString* title =
[self runConfirmationDialogWithTitle:@"Cancel Download?" l10n_util::GetNSString(IDS_IOS_DOWNLOAD_MANAGER_CANCEL_CONFIRMATION);
[self runConfirmationDialogWithTitle:title
message:nil message:nil
completionHandler:^(BOOL confirmed) { completionHandler:^(BOOL confirmed) {
if (confirmed) { if (confirmed) {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#import "ios/chrome/browser/ui/download/download_manager_view_controller.h" #import "ios/chrome/browser/ui/download/download_manager_view_controller.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/strings/sys_string_conversions.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#import "ios/chrome/browser/ui/util/named_guide.h" #import "ios/chrome/browser/ui/util/named_guide.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
...@@ -334,8 +335,9 @@ NSString* GetSizeString(long long size_in_bytes) { ...@@ -334,8 +335,9 @@ NSString* GetSizeString(long long size_in_bytes) {
[_installDriveButton addTarget:self [_installDriveButton addTarget:self
action:@selector(didTapInstallDriveButton) action:@selector(didTapInstallDriveButton)
forControlEvents:UIControlEventTouchUpInside]; forControlEvents:UIControlEventTouchUpInside];
// TODO(crbug.com/805533): Localize this string. [_installDriveButton
[_installDriveButton setTitle:@"Install" forState:UIControlStateNormal]; setTitle:l10n_util::GetNSString(IDS_IOS_DOWNLOAD_MANAGER_INSTALL)
forState:UIControlStateNormal];
} }
return _installDriveButton; return _installDriveButton;
} }
...@@ -423,11 +425,11 @@ NSString* GetSizeString(long long size_in_bytes) { ...@@ -423,11 +425,11 @@ NSString* GetSizeString(long long size_in_bytes) {
_countOfBytesExpectedToReceive)]; _countOfBytesExpectedToReceive)];
} }
break; break;
case kDownloadManagerStateInProgress: case kDownloadManagerStateInProgress: {
// TODO(crbug.com/805533): Localize this string. base::string16 size =
statusText = base::SysNSStringToUTF16(GetSizeString(_countOfBytesReceived));
[NSString stringWithFormat:@"Downloading... %@", statusText = l10n_util::GetNSStringF(
GetSizeString(_countOfBytesReceived)]; IDS_IOS_DOWNLOAD_MANAGER_DOWNLOADING_ELIPSIS, size);
if (_countOfBytesExpectedToReceive != -1) { if (_countOfBytesExpectedToReceive != -1) {
statusText = [statusText statusText = [statusText
stringByAppendingFormat:@"/%@", stringByAppendingFormat:@"/%@",
...@@ -435,12 +437,13 @@ NSString* GetSizeString(long long size_in_bytes) { ...@@ -435,12 +437,13 @@ NSString* GetSizeString(long long size_in_bytes) {
_countOfBytesExpectedToReceive)]; _countOfBytesExpectedToReceive)];
} }
break; break;
}
case kDownloadManagerStateSuceeded: case kDownloadManagerStateSuceeded:
statusText = _fileName; statusText = _fileName;
break; break;
case kDownloadManagerStateFailed: case kDownloadManagerStateFailed:
// TODO(crbug.com/805533): Localize this string. statusText =
statusText = @"Couldn't Download"; l10n_util::GetNSString(IDS_IOS_DOWNLOAD_MANAGER_COULDNT_DOWNLOAD);
break; break;
} }
...@@ -453,18 +456,15 @@ NSString* GetSizeString(long long size_in_bytes) { ...@@ -453,18 +456,15 @@ NSString* GetSizeString(long long size_in_bytes) {
NSString* title = nil; NSString* title = nil;
switch (_state) { switch (_state) {
case kDownloadManagerStateNotStarted: case kDownloadManagerStateNotStarted:
// TODO(crbug.com/805533): Localize this string. title = l10n_util::GetNSString(IDS_IOS_DOWNLOAD_MANAGER_DOWNLOAD);
title = @"Download";
break; break;
case kDownloadManagerStateInProgress: case kDownloadManagerStateInProgress:
break; break;
case kDownloadManagerStateSuceeded: case kDownloadManagerStateSuceeded:
// TODO(crbug.com/805533): Localize this string. title = l10n_util::GetNSString(IDS_IOS_OPEN_IN);
title = @"Open In...";
break; break;
case kDownloadManagerStateFailed: case kDownloadManagerStateFailed:
// TODO(crbug.com/805533): Localize this string. title = l10n_util::GetNSString(IDS_IOS_DOWNLOAD_MANAGER_TRY_AGAIN);
title = @"Try Again";
break; break;
} }
......
...@@ -54,8 +54,7 @@ TEST_F(DownloadManagerViewControllerTest, InProgressWithLongFileName) { ...@@ -54,8 +54,7 @@ TEST_F(DownloadManagerViewControllerTest, InProgressWithLongFileName) {
view_controller_.fileName = @"longfilenamesolongthatitbarelyfitwidthlimit"; view_controller_.fileName = @"longfilenamesolongthatitbarelyfitwidthlimit";
view_controller_.countOfBytesExpectedToReceive = 10 * 1024; view_controller_.countOfBytesExpectedToReceive = 10 * 1024;
EXPECT_NSEQ(@"Downloading... Zero KB/10 KB", EXPECT_NSEQ(@"Downloading… Zero KB/10 KB", view_controller_.statusLabel.text);
view_controller_.statusLabel.text);
EXPECT_TRUE(view_controller_.actionButton.hidden); EXPECT_TRUE(view_controller_.actionButton.hidden);
} }
...@@ -68,7 +67,7 @@ TEST_F(DownloadManagerViewControllerTest, ...@@ -68,7 +67,7 @@ TEST_F(DownloadManagerViewControllerTest,
view_controller_.countOfBytesReceived = 900; view_controller_.countOfBytesReceived = 900;
view_controller_.countOfBytesExpectedToReceive = -1; view_controller_.countOfBytesExpectedToReceive = -1;
EXPECT_NSEQ(@"Downloading... 900 bytes", view_controller_.statusLabel.text); EXPECT_NSEQ(@"Downloading 900 bytes", view_controller_.statusLabel.text);
EXPECT_TRUE(view_controller_.actionButton.hidden); EXPECT_TRUE(view_controller_.actionButton.hidden);
} }
...@@ -79,8 +78,8 @@ TEST_F(DownloadManagerViewControllerTest, SuceededWithWithLongFileName) { ...@@ -79,8 +78,8 @@ TEST_F(DownloadManagerViewControllerTest, SuceededWithWithLongFileName) {
view_controller_.countOfBytesReceived = 1024; view_controller_.countOfBytesReceived = 1024;
EXPECT_NSEQ(@"file.txt", view_controller_.statusLabel.text); EXPECT_NSEQ(@"file.txt", view_controller_.statusLabel.text);
EXPECT_NSEQ(@"Open In...", [view_controller_.actionButton EXPECT_NSEQ(@"Open in…", [view_controller_.actionButton
titleForState:UIControlStateNormal]); titleForState:UIControlStateNormal]);
} }
// Tests label and button titles with kDownloadManagerStateFailed state. // Tests label and button titles with kDownloadManagerStateFailed state.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment