Commit f287b765 authored by Yuwei Huang's avatar Yuwei Huang Committed by Commit Bot

[CRD iOS] Basic I18N work

This CL makes the app build with i18n resources and replaces some
hardcoded texts with the localized strings.

Follow up CLs will be needed to fully localize the app.

Bug: 
Change-Id: I78476ed413e0283b56d7053418ec47138d4d72f5
Reviewed-on: https://chromium-review.googlesource.com/578187Reviewed-by: default avatarScott Nichols <nicholss@chromium.org>
Commit-Queue: Yuwei Huang <yuweih@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488077}
parent f9304249
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import("//remoting/build/config/remoting_build.gni")
import("//remoting/ios/app/remoting_ios_tmpl.gni") import("//remoting/ios/app/remoting_ios_tmpl.gni")
group("all") { group("all") {
...@@ -12,6 +13,20 @@ group("all") { ...@@ -12,6 +13,20 @@ group("all") {
] ]
} }
foreach(locale, remoting_locales_with_underscores) {
bundle_data("locale_${locale}_bundle_data") {
sources = [
"$root_out_dir/remoting/resources/$locale.lproj/locale.pak",
]
outputs = [
"{{bundle_resources_dir}}/$locale.lproj/{{source_file_part}}",
]
public_deps = [
"//remoting/resources:copy_locales",
]
}
}
# source set to be used by both external and internal app. # source set to be used by both external and internal app.
source_set("common_source_set") { source_set("common_source_set") {
sources = [ sources = [
...@@ -78,11 +93,16 @@ source_set("common_source_set") { ...@@ -78,11 +93,16 @@ source_set("common_source_set") {
"//remoting/ios/mdc", "//remoting/ios/mdc",
"//remoting/ios/persistence", "//remoting/ios/persistence",
"//remoting/protocol", "//remoting/protocol",
"//remoting/resources",
"//ui/base", "//ui/base",
"//ui/gfx", "//ui/gfx",
"//ui/resources", "//ui/resources",
] ]
foreach(locale, remoting_locales_with_underscores) {
deps += [ ":locale_${locale}_bundle_data" ]
}
public_deps = [ public_deps = [
"//ios/third_party/material_components_ios", "//ios/third_party/material_components_ios",
] ]
......
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
#import "ios/third_party/material_components_ios/src/components/Buttons/src/MaterialButtons.h" #import "ios/third_party/material_components_ios/src/components/Buttons/src/MaterialButtons.h"
#import "remoting/ios/app/remoting_theme.h" #import "remoting/ios/app/remoting_theme.h"
#include "remoting/base/string_resources.h"
#include "ui/base/l10n/l10n_util.h"
static const float kLogoSizeMultiplier = 0.381966f; static const float kLogoSizeMultiplier = 0.381966f;
static const float kLogoYOffset = -10.f; static const float kLogoYOffset = -10.f;
static const float kButtonHeight = 80.f; static const float kButtonHeight = 80.f;
...@@ -34,7 +37,8 @@ static const float kButtonHeight = 80.f; ...@@ -34,7 +37,8 @@ static const float kButtonHeight = 80.f;
[self.view addSubview:imageView]; [self.view addSubview:imageView];
MDCFlatButton* signInButton = [[MDCFlatButton alloc] init]; MDCFlatButton* signInButton = [[MDCFlatButton alloc] init];
[signInButton setTitle:@"Sign in" forState:UIControlStateNormal]; [signInButton setTitle:l10n_util::GetNSString(IDS_SIGN_IN_BUTTON)
forState:UIControlStateNormal];
[signInButton sizeToFit]; [signInButton sizeToFit];
[signInButton addTarget:self [signInButton addTarget:self
action:@selector(didTapSignIn:) action:@selector(didTapSignIn:)
......
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
#import "remoting/ios/app/help_view_controller.h" #import "remoting/ios/app/help_view_controller.h"
#include "remoting/base/string_resources.h"
#include "ui/base/l10n/l10n_util.h"
// TODO(nicholss): These urls should come from a global config. // TODO(nicholss): These urls should come from a global config.
static NSString* const kHelpCenterUrl = static NSString* const kHelpCenterUrl =
@"https://support.google.com/chrome/answer/1649523?co=GENIE.Platform%3DiOS"; @"https://support.google.com/chrome/answer/1649523?co=GENIE.Platform%3DiOS";
...@@ -20,8 +23,8 @@ static NSString* const kCreditsUrlString = ...@@ -20,8 +23,8 @@ static NSString* const kCreditsUrlString =
- (instancetype)init { - (instancetype)init {
if (self = [super initWithUrl:kHelpCenterUrl title:@"Help Center"]) { if (self = [super initWithUrl:kHelpCenterUrl title:@"Help Center"]) {
self.navigationItem.rightBarButtonItem = self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
[[UIBarButtonItem alloc] initWithTitle:@"Credits" initWithTitle:l10n_util::GetNSString(IDS_CREDITS)
style:UIBarButtonItemStylePlain style:UIBarButtonItemStylePlain
target:self target:self
action:@selector(onTapCredits:)]; action:@selector(onTapCredits:)];
...@@ -32,9 +35,9 @@ static NSString* const kCreditsUrlString = ...@@ -32,9 +35,9 @@ static NSString* const kCreditsUrlString =
#pragma mark - Private #pragma mark - Private
- (void)onTapCredits:(id)button { - (void)onTapCredits:(id)button {
WebViewController* creditsVC = WebViewController* creditsVC = [[WebViewController alloc]
[[WebViewController alloc] initWithUrl:kCreditsUrlString initWithUrl:kCreditsUrlString
title:@"Credits"]; title:l10n_util::GetNSString(IDS_CREDITS)];
[self.navigationController pushViewController:creditsVC animated:YES]; [self.navigationController pushViewController:creditsVC animated:YES];
} }
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "base/at_exit.h" #include "base/at_exit.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/i18n/icu_util.h" #include "base/i18n/icu_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
// This class is designed to fulfill the dependents needs when it goes out of // This class is designed to fulfill the dependents needs when it goes out of
...@@ -32,6 +34,11 @@ int main(int argc, char* argv[]) { ...@@ -32,6 +34,11 @@ int main(int argc, char* argv[]) {
logging::SetMinLogLevel(-1); logging::SetMinLogLevel(-1);
#endif #endif
l10n_util::OverrideLocaleWithCocoaLocale();
ui::ResourceBundle::InitSharedInstanceWithLocale(
"" /* Overridden by cocal locale */, NULL,
ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES);
@autoreleasepool { @autoreleasepool {
[AppInitializer initializeApp]; [AppInitializer initializeApp];
return UIApplicationMain( return UIApplicationMain(
......
...@@ -28,7 +28,9 @@ ...@@ -28,7 +28,9 @@
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "remoting/base/oauth_token_getter.h" #include "remoting/base/oauth_token_getter.h"
#include "remoting/base/string_resources.h"
#include "remoting/client/connect_to_host_info.h" #include "remoting/client/connect_to_host_info.h"
#include "ui/base/l10n/l10n_util.h"
static CGFloat kHostInset = 5.f; static CGFloat kHostInset = 5.f;
...@@ -74,7 +76,8 @@ static CGFloat kHostInset = 5.f; ...@@ -74,7 +76,8 @@ static CGFloat kHostInset = 5.f;
_appBar = [[MDCAppBar alloc] init]; _appBar = [[MDCAppBar alloc] init];
[self addChildViewController:_appBar.headerViewController]; [self addChildViewController:_appBar.headerViewController];
self.navigationItem.title = @"chrome remote desktop"; self.navigationItem.title =
l10n_util::GetNSString(IDS_PRODUCT_NAME).lowercaseString;
UIBarButtonItem* menuButton = UIBarButtonItem* menuButton =
[[UIBarButtonItem alloc] initWithImage:RemotingTheme.menuIcon [[UIBarButtonItem alloc] initWithImage:RemotingTheme.menuIcon
...@@ -163,7 +166,7 @@ static CGFloat kHostInset = 5.f; ...@@ -163,7 +166,7 @@ static CGFloat kHostInset = 5.f;
completion:(void (^)())completionBlock { completion:(void (^)())completionBlock {
if (![cell.hostInfo isOnline]) { if (![cell.hostInfo isOnline]) {
MDCSnackbarMessage* message = [[MDCSnackbarMessage alloc] init]; MDCSnackbarMessage* message = [[MDCSnackbarMessage alloc] init];
message.text = @"Host is offline."; message.text = l10n_util::GetNSString(IDS_HOST_OFFLINE_TOOLTIP);
[MDCSnackbarManager showMessage:message]; [MDCSnackbarManager showMessage:message];
return; return;
} }
......
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
#import "ios/third_party/material_components_ios/src/components/Buttons/src/MaterialButtons.h" #import "ios/third_party/material_components_ios/src/components/Buttons/src/MaterialButtons.h"
#import "remoting/ios/app/remoting_theme.h" #import "remoting/ios/app/remoting_theme.h"
#include "remoting/base/string_resources.h"
#include "ui/base/l10n/l10n_util.h"
static const CGFloat kReconnectButtonWidth = 120.f; static const CGFloat kReconnectButtonWidth = 120.f;
static const CGFloat kReconnectButtonHeight = 30.f; static const CGFloat kReconnectButtonHeight = 30.f;
...@@ -30,7 +33,8 @@ static const CGFloat kReconnectButtonHeight = 30.f; ...@@ -30,7 +33,8 @@ static const CGFloat kReconnectButtonHeight = 30.f;
_reconnectButton = [[MDCRaisedButton alloc] init]; _reconnectButton = [[MDCRaisedButton alloc] init];
[_reconnectButton setElevation:4.0f forState:UIControlStateNormal]; [_reconnectButton setElevation:4.0f forState:UIControlStateNormal];
[_reconnectButton setTitle:@"Reconnect" forState:UIControlStateNormal]; [_reconnectButton setTitle:l10n_util::GetNSString(IDS_RECONNECT)
forState:UIControlStateNormal];
[_reconnectButton addTarget:self [_reconnectButton addTarget:self
action:@selector(didTapReconnect:) action:@selector(didTapReconnect:)
forControlEvents:UIControlEventTouchUpInside]; forControlEvents:UIControlEventTouchUpInside];
......
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
#import "remoting/ios/app/app_delegate.h" #import "remoting/ios/app/app_delegate.h"
#import "remoting/ios/app/remoting_theme.h" #import "remoting/ios/app/remoting_theme.h"
#include "remoting/base/string_resources.h"
#include "ui/base/l10n/l10n_util.h"
static NSString* const kFeedbackContext = @"SideMenuFeedbackContext"; static NSString* const kFeedbackContext = @"SideMenuFeedbackContext";
#pragma mark - SideMenuItem #pragma mark - SideMenuItem
...@@ -50,13 +53,14 @@ static NSString* const kFeedbackContext = @"SideMenuFeedbackContext"; ...@@ -50,13 +53,14 @@ static NSString* const kFeedbackContext = @"SideMenuFeedbackContext";
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
items = @[ @[ items = @[ @[
[[SideMenuItem alloc] [[SideMenuItem alloc]
initWithTitle:@"Send Feedback" initWithTitle:l10n_util::GetNSString(IDS_ACTIONBAR_SEND_FEEDBACK)
icon:RemotingTheme.feedbackIcon icon:RemotingTheme.feedbackIcon
action:^{ action:^{
[AppDelegate.instance [AppDelegate.instance
presentFeedbackFlowWithContext:kFeedbackContext]; presentFeedbackFlowWithContext:kFeedbackContext];
}], }],
[[SideMenuItem alloc] initWithTitle:@"Help" [[SideMenuItem alloc]
initWithTitle:l10n_util::GetNSString(IDS_ACTIONBAR_HELP)
icon:RemotingTheme.helpIcon icon:RemotingTheme.helpIcon
action:^{ action:^{
[AppDelegate.instance presentHelpCenter]; [AppDelegate.instance presentHelpCenter];
......
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