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 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//remoting/build/config/remoting_build.gni")
import("//remoting/ios/app/remoting_ios_tmpl.gni")
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("common_source_set") {
sources = [
......@@ -78,11 +93,16 @@ source_set("common_source_set") {
"//remoting/ios/mdc",
"//remoting/ios/persistence",
"//remoting/protocol",
"//remoting/resources",
"//ui/base",
"//ui/gfx",
"//ui/resources",
]
foreach(locale, remoting_locales_with_underscores) {
deps += [ ":locale_${locale}_bundle_data" ]
}
public_deps = [
"//ios/third_party/material_components_ios",
]
......
......@@ -11,6 +11,9 @@
#import "ios/third_party/material_components_ios/src/components/Buttons/src/MaterialButtons.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 kLogoYOffset = -10.f;
static const float kButtonHeight = 80.f;
......@@ -34,7 +37,8 @@ static const float kButtonHeight = 80.f;
[self.view addSubview:imageView];
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 addTarget:self
action:@selector(didTapSignIn:)
......
......@@ -8,6 +8,9 @@
#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.
static NSString* const kHelpCenterUrl =
@"https://support.google.com/chrome/answer/1649523?co=GENIE.Platform%3DiOS";
......@@ -20,11 +23,11 @@ static NSString* const kCreditsUrlString =
- (instancetype)init {
if (self = [super initWithUrl:kHelpCenterUrl title:@"Help Center"]) {
self.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:@"Credits"
style:UIBarButtonItemStylePlain
target:self
action:@selector(onTapCredits:)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
initWithTitle:l10n_util::GetNSString(IDS_CREDITS)
style:UIBarButtonItemStylePlain
target:self
action:@selector(onTapCredits:)];
}
return self;
}
......@@ -32,9 +35,9 @@ static NSString* const kCreditsUrlString =
#pragma mark - Private
- (void)onTapCredits:(id)button {
WebViewController* creditsVC =
[[WebViewController alloc] initWithUrl:kCreditsUrlString
title:@"Credits"];
WebViewController* creditsVC = [[WebViewController alloc]
initWithUrl:kCreditsUrlString
title:l10n_util::GetNSString(IDS_CREDITS)];
[self.navigationController pushViewController:creditsVC animated:YES];
}
......
......@@ -14,6 +14,8 @@
#include "base/at_exit.h"
#include "base/command_line.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[]) {
// This class is designed to fulfill the dependents needs when it goes out of
......@@ -32,6 +34,11 @@ int main(int argc, char* argv[]) {
logging::SetMinLogLevel(-1);
#endif
l10n_util::OverrideLocaleWithCocoaLocale();
ui::ResourceBundle::InitSharedInstanceWithLocale(
"" /* Overridden by cocal locale */, NULL,
ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES);
@autoreleasepool {
[AppInitializer initializeApp];
return UIApplicationMain(
......
......@@ -28,7 +28,9 @@
#include "base/strings/sys_string_conversions.h"
#include "remoting/base/oauth_token_getter.h"
#include "remoting/base/string_resources.h"
#include "remoting/client/connect_to_host_info.h"
#include "ui/base/l10n/l10n_util.h"
static CGFloat kHostInset = 5.f;
......@@ -74,7 +76,8 @@ static CGFloat kHostInset = 5.f;
_appBar = [[MDCAppBar alloc] init];
[self addChildViewController:_appBar.headerViewController];
self.navigationItem.title = @"chrome remote desktop";
self.navigationItem.title =
l10n_util::GetNSString(IDS_PRODUCT_NAME).lowercaseString;
UIBarButtonItem* menuButton =
[[UIBarButtonItem alloc] initWithImage:RemotingTheme.menuIcon
......@@ -163,7 +166,7 @@ static CGFloat kHostInset = 5.f;
completion:(void (^)())completionBlock {
if (![cell.hostInfo isOnline]) {
MDCSnackbarMessage* message = [[MDCSnackbarMessage alloc] init];
message.text = @"Host is offline.";
message.text = l10n_util::GetNSString(IDS_HOST_OFFLINE_TOOLTIP);
[MDCSnackbarManager showMessage:message];
return;
}
......
......@@ -11,6 +11,9 @@
#import "ios/third_party/material_components_ios/src/components/Buttons/src/MaterialButtons.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 kReconnectButtonHeight = 30.f;
......@@ -30,7 +33,8 @@ static const CGFloat kReconnectButtonHeight = 30.f;
_reconnectButton = [[MDCRaisedButton alloc] init];
[_reconnectButton setElevation:4.0f forState:UIControlStateNormal];
[_reconnectButton setTitle:@"Reconnect" forState:UIControlStateNormal];
[_reconnectButton setTitle:l10n_util::GetNSString(IDS_RECONNECT)
forState:UIControlStateNormal];
[_reconnectButton addTarget:self
action:@selector(didTapReconnect:)
forControlEvents:UIControlEventTouchUpInside];
......
......@@ -11,6 +11,9 @@
#import "remoting/ios/app/app_delegate.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";
#pragma mark - SideMenuItem
......@@ -50,17 +53,18 @@ static NSString* const kFeedbackContext = @"SideMenuFeedbackContext";
dispatch_once(&onceToken, ^{
items = @[ @[
[[SideMenuItem alloc]
initWithTitle:@"Send Feedback"
initWithTitle:l10n_util::GetNSString(IDS_ACTIONBAR_SEND_FEEDBACK)
icon:RemotingTheme.feedbackIcon
action:^{
[AppDelegate.instance
presentFeedbackFlowWithContext:kFeedbackContext];
}],
[[SideMenuItem alloc] initWithTitle:@"Help"
icon:RemotingTheme.helpIcon
action:^{
[AppDelegate.instance presentHelpCenter];
}],
[[SideMenuItem alloc]
initWithTitle:l10n_util::GetNSString(IDS_ACTIONBAR_HELP)
icon:RemotingTheme.helpIcon
action:^{
[AppDelegate.instance presentHelpCenter];
}],
] ];
});
return items;
......
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