summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2017-09-26 12:57:27 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2017-10-05 08:00:37 +0000
commit9642bc462f4ce6422b46a3426d34a21c18a9750d (patch)
treed37f55b73c5b608e1154422ca2cd6cbdac56f0fb
parentd044140246734b8851689f55197c03cfd29dec99 (diff)
Fix localization of descriptions in directory listing pages
We never replaced the variable values in the HTML template for directory listings. Task-number: QTBUG-63377 Change-Id: I5cd3d44ef253f6ed2e18f7e0cd4324c000c31dde Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--src/core/content_main_delegate_qt.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp
index 720db77b..359e0b3d 100644
--- a/src/core/content_main_delegate_qt.cpp
+++ b/src/core/content_main_delegate_qt.cpp
@@ -40,19 +40,23 @@
#include "content_main_delegate_qt.h"
#include "base/command_line.h"
+#include <base/i18n/rtl.h>
#include "base/logging.h"
#include "base/path_service.h"
#include "base/strings/string_number_conversions.h"
+#include <chrome/grit/generated_resources.h>
#include "content/public/common/content_paths.h"
#include "content/public/common/content_switches.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/ui_base_paths.h"
#include "ui/base/resource/resource_bundle.h"
+#include <ui/base/webui/jstemplate_builder.h>
#include "net/grit/net_resources.h"
#include "net/base/net_module.h"
#include "content_client_qt.h"
#include "renderer/content_renderer_client_qt.h"
+#include "type_conversion.h"
#include "web_engine_library_info.h"
#if defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX))
@@ -63,12 +67,38 @@
#include "ui/base/ui_base_switches.h"
#endif
+#include <QtCore/qcoreapplication.h>
+
namespace QtWebEngineCore {
+// The logic of this function is based on chrome/common/net/net_resource_provider.cc
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE.Chromium file.
+static std::string constructDirHeaderHTML()
+{
+ base::DictionaryValue dict;
+ dict.SetString("header", l10n_util::GetStringUTF16(IDS_DIRECTORY_LISTING_HEADER));
+ dict.SetString("parentDirText", l10n_util::GetStringUTF16(IDS_DIRECTORY_LISTING_PARENT));
+ dict.SetString("headerName", l10n_util::GetStringUTF16(IDS_DIRECTORY_LISTING_NAME));
+ dict.SetString("headerSize", l10n_util::GetStringUTF16(IDS_DIRECTORY_LISTING_SIZE));
+ dict.SetString("headerDateModified",
+ l10n_util::GetStringUTF16(IDS_DIRECTORY_LISTING_DATE_MODIFIED));
+ dict.SetString("language", l10n_util::GetLanguage(base::i18n::GetConfiguredLocale()));
+ dict.SetString("listingParsingErrorBoxText",
+ l10n_util::GetStringFUTF16(IDS_DIRECTORY_LISTING_PARSING_ERROR_BOX_TEXT,
+ toString16(QCoreApplication::applicationName())));
+ dict.SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr");
+ std::string html = webui::GetI18nTemplateHtml(
+ ui::ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_DIR_HEADER_HTML),
+ &dict);
+ return html;
+}
+
static base::StringPiece PlatformResourceProvider(int key) {
if (key == IDR_DIR_HEADER_HTML) {
- base::StringPiece html_data = ui::ResourceBundle::GetSharedInstance().GetRawDataResource(IDR_DIR_HEADER_HTML);
- return html_data;
+ static std::string html_data = constructDirHeaderHTML();
+ return base::StringPiece(html_data);
}
return base::StringPiece();
}