Commit 5fd55b4b authored by Hector Carmona's avatar Hector Carmona Committed by Commit Bot

Navi: Localize Google Apps strings.

Bug: 894499
Change-Id: I698b51eac47cdb7af63e4bb2ace338f87c5e7493
Reviewed-on: https://chromium-review.googlesource.com/c/1351779Reviewed-by: default avatarScott Chen <scottchen@chromium.org>
Commit-Queue: Hector Carmona <hcarmona@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611759}
parent c4d43d0d
......@@ -35,6 +35,36 @@
<message name="IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_DESCRIPTION" desc="Description of what this section in the onboarding workflow does.">
Add bookmarks to your favorite Google Apps
</message>
<message name="IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_MAPS" desc="Label for a button that creates a bookmark to maps.google.com, this should be the name of the brand.">
Maps
</message>
<message name="IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_MAPS_LINK" desc="URL for the Google Maps website, this should be the replaced with a locale specific URL if it exists.">
https://maps.google.com
</message>
<message name="IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_NEWS" desc="Label for a button that creates a bookmark to news.google.com, this should be the name of the brand.">
News
</message>
<message name="IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_NEWS_LINK" desc="URL for the Google News website, this should be the replaced with a locale specific URL if it exists.">
https://news.google.com
</message>
<message name="IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_TRANSLATE" desc="Label for a button that creates a bookmark to translate.google.com, this should be the name of the brand.">
Translate
</message>
<message name="IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_TRANSLATE_LINK" desc="URL for the Google Translate website, this should be the replaced with a locale specific URL if it exists.">
https://translate.google.com
</message>
<message name="IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_WEB_STORE" desc="Label for a button that creates a bookmark to chrome.google.com/webstore, this should be the name of the brand.">
Web Store
</message>
<message name="IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_WEB_STORE_LINK" desc="URL for the Chrome Webstore website, this should be the replaced with a locale specific URL if it exists.">
https://chrome.google.com/webstore
</message>
<message name="IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_YOUTUBE" desc="Label for a button that creates a bookmark to youtube.com, this should be the name of the brand.">
YouTube
</message>
<message name="IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_YOUTUBE_LINK" desc="URL for the YouTube website, this should be the replaced with a locale specific URL if it exists.">
https://youtube.com
</message>
<!-- NUX set default module -->
<message name="IDS_ONBOARDING_WELCOME_NUX_SET_AS_DEFAULT_HEADER" desc="Header for the page that prompts user to set Chrome as their default browser.">
......
......@@ -6,6 +6,7 @@
#define CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_BOOKMARK_ITEM_H_
#include <stddef.h>
#include <string>
namespace base {
class ListValue;
......@@ -15,9 +16,9 @@ namespace nux {
struct BookmarkItem {
const int id;
const char* name;
const std::string name;
const char* webui_icon;
const char* url;
const std::string url;
const int icon; // Corresponds with resource ID, used for bookmark cache.
};
......
......@@ -19,6 +19,7 @@
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
namespace nux {
......@@ -38,24 +39,48 @@ enum class GoogleApps {
const char* kGoogleAppsInteractionHistogram =
"FirstRun.NewUserExperience.GoogleAppsInteraction";
// Strings in costants not translated because this is an experiment.
// TODO(hcarmona): Translate before wide release.
const BookmarkItem kGoogleApps[] = {
{static_cast<int>(GoogleApps::kYouTube), "YouTube", "youtube",
"https://youtube.com", IDR_NUX_GOOGLE_APPS_YOUTUBE_1X},
{static_cast<int>(GoogleApps::kMaps), "Maps", "maps",
"https://maps.google.com", IDR_NUX_GOOGLE_APPS_MAPS_1X},
{static_cast<int>(GoogleApps::kNews), "News", "news",
"https://news.google.com", IDR_NUX_GOOGLE_APPS_NEWS_1X},
{static_cast<int>(GoogleApps::kTranslate), "Translate", "translate",
"https://translate.google.com", IDR_NUX_GOOGLE_APPS_TRANSLATE_1X},
{static_cast<int>(GoogleApps::kChromeWebStore), "Web Store", "web-store",
"https://chrome.google.com/webstore", IDR_NUX_GOOGLE_APPS_CHROME_STORE_1X},
};
constexpr const int kGoogleAppIconSize = 48; // Pixels.
GoogleAppsHandler::GoogleAppsHandler() {}
GoogleAppsHandler::GoogleAppsHandler()
: // Do not translate icon name as it is not human visible and needs to
// match CSS.
google_apps_{{
{static_cast<int>(GoogleApps::kYouTube),
l10n_util::GetStringUTF8(
IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_YOUTUBE),
"youtube",
l10n_util::GetStringUTF8(
IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_YOUTUBE_LINK),
IDR_NUX_GOOGLE_APPS_YOUTUBE_1X},
{static_cast<int>(GoogleApps::kMaps),
l10n_util::GetStringUTF8(
IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_MAPS),
"maps",
l10n_util::GetStringUTF8(
IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_MAPS_LINK),
IDR_NUX_GOOGLE_APPS_MAPS_1X},
{static_cast<int>(GoogleApps::kNews),
l10n_util::GetStringUTF8(
IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_NEWS),
"news",
l10n_util::GetStringUTF8(
IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_NEWS_LINK),
IDR_NUX_GOOGLE_APPS_NEWS_1X},
{static_cast<int>(GoogleApps::kTranslate),
l10n_util::GetStringUTF8(
IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_TRANSLATE),
"translate",
l10n_util::GetStringUTF8(
IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_TRANSLATE_LINK),
IDR_NUX_GOOGLE_APPS_TRANSLATE_1X},
{static_cast<int>(GoogleApps::kChromeWebStore),
l10n_util::GetStringUTF8(
IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_WEB_STORE),
"web-store",
l10n_util::GetStringUTF8(
IDS_ONBOARDING_WELCOME_NUX_GOOGLE_APPS_WEB_STORE_LINK),
IDR_NUX_GOOGLE_APPS_CHROME_STORE_1X},
}} {}
GoogleAppsHandler::~GoogleAppsHandler() {}
......@@ -76,9 +101,9 @@ void GoogleAppsHandler::HandleCacheGoogleAppIcon(const base::ListValue* args) {
args->GetInteger(0, &appId);
const BookmarkItem* selectedApp = NULL;
for (size_t i = 0; i < base::size(kGoogleApps); i++) {
if (static_cast<int>(kGoogleApps[i].id) == appId) {
selectedApp = &kGoogleApps[i];
for (size_t i = 0; i < kGoogleAppCount; i++) {
if (static_cast<int>(google_apps_[i].id) == appId) {
selectedApp = &google_apps_[i];
break;
}
}
......@@ -104,7 +129,7 @@ void GoogleAppsHandler::HandleGetGoogleAppsList(const base::ListValue* args) {
CHECK(args->Get(0, &callback_id));
ResolveJavascriptCallback(
*callback_id,
bookmarkItemsToListValue(kGoogleApps, base::size(kGoogleApps)));
bookmarkItemsToListValue(google_apps_.data(), kGoogleAppCount));
}
} // namespace nux
......@@ -5,8 +5,11 @@
#ifndef CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_GOOGLE_APPS_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_WELCOME_NUX_GOOGLE_APPS_HANDLER_H_
#include <array>
#include "base/macros.h"
#include "base/values.h"
#include "chrome/browser/ui/webui/welcome/nux/bookmark_item.h"
#include "content/public/browser/web_ui_message_handler.h"
namespace nux {
......@@ -22,6 +25,8 @@ enum class GoogleAppsInteraction {
kCount,
};
const size_t kGoogleAppCount = 5;
class GoogleAppsHandler : public content::WebUIMessageHandler {
public:
GoogleAppsHandler();
......@@ -34,6 +39,9 @@ class GoogleAppsHandler : public content::WebUIMessageHandler {
void HandleCacheGoogleAppIcon(const base::ListValue* args);
void HandleGetGoogleAppsList(const base::ListValue* args);
private:
std::array<BookmarkItem, kGoogleAppCount> google_apps_;
DISALLOW_COPY_AND_ASSIGN(GoogleAppsHandler);
};
......
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