diff options
-rw-r--r-- | src/core/content_browser_client_qt.cpp | 14 | ||||
-rw-r--r-- | src/core/content_browser_client_qt.h | 1 | ||||
-rw-r--r-- | src/core/content_main_delegate_qt.cpp | 2 | ||||
-rw-r--r-- | src/core/web_engine_library_info.cpp | 11 | ||||
-rw-r--r-- | src/core/web_engine_library_info.h | 1 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/tst_qmltests.cpp | 3 |
6 files changed, 30 insertions, 2 deletions
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 60ca493ca..3d318047b 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -48,8 +48,10 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/resource_dispatcher_host.h" #include "content/public/browser/web_contents.h" +#include "content/public/common/content_switches.h" #include "content/public/common/main_function_params.h" #include "content/public/common/url_constants.h" +#include "ui/base/ui_base_switches.h" #include "ui/gfx/screen.h" #include "ui/gl/gl_context.h" #include "ui/gl/gl_implementation.h" @@ -69,6 +71,7 @@ #include "resource_dispatcher_host_delegate_qt.h" #include "user_script_controller_host.h" #include "web_contents_delegate_qt.h" +#include "web_engine_library_info.h" #include <QGuiApplication> #include <QLocale> @@ -441,7 +444,16 @@ content::LocationProvider *ContentBrowserClientQt::OverrideSystemLocationProvide std::string ContentBrowserClientQt::GetApplicationLocale() { - return QLocale().bcp47Name().toStdString(); + return WebEngineLibraryInfo::getApplicationLocale(); +} + +void ContentBrowserClientQt::AppendExtraCommandLineSwitches(base::CommandLine* command_line, int child_process_id) +{ + Q_UNUSED(child_process_id); + + std::string processType = command_line->GetSwitchValueASCII(switches::kProcessType); + if (processType == switches::kZygoteProcess) + command_line->AppendSwitchASCII(switches::kLang, GetApplicationLocale()); } content::DevToolsManagerDelegate* ContentBrowserClientQt::GetDevToolsManagerDelegate() diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h index bce8f70e9..0af5ae9d3 100644 --- a/src/core/content_browser_client_qt.h +++ b/src/core/content_browser_client_qt.h @@ -114,6 +114,7 @@ public: virtual blink::WebNotificationPermission CheckDesktopNotificationPermission(const GURL& source_origin, content::ResourceContext* context, int render_process_id) Q_DECL_OVERRIDE; virtual std::string GetApplicationLocale() Q_DECL_OVERRIDE; + virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line, int child_process_id) Q_DECL_OVERRIDE; private: BrowserMainPartsQt* m_browserMainParts; diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp index b8e40a448..4003823b1 100644 --- a/src/core/content_main_delegate_qt.cpp +++ b/src/core/content_main_delegate_qt.cpp @@ -67,7 +67,7 @@ static base::StringPiece PlatformResourceProvider(int key) { void ContentMainDelegateQt::PreSandboxStartup() { net::NetModule::SetResourceProvider(PlatformResourceProvider); - ui::ResourceBundle::InitSharedInstanceWithLocale(QLocale().name().toStdString(), 0, ui::ResourceBundle::LOAD_COMMON_RESOURCES); + ui::ResourceBundle::InitSharedInstanceWithLocale(WebEngineLibraryInfo::getApplicationLocale(), 0, ui::ResourceBundle::LOAD_COMMON_RESOURCES); // Suppress info, warning and error messages per default. int logLevel = logging::LOG_FATAL; diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp index 17f6b2a05..e78ab09e7 100644 --- a/src/core/web_engine_library_info.cpp +++ b/src/core/web_engine_library_info.cpp @@ -38,9 +38,11 @@ #include "web_engine_library_info.h" #include "base/base_paths.h" +#include "base/command_line.h" #include "base/files/file_util.h" #include "content/public/common/content_paths.h" #include "ui/base/ui_base_paths.h" +#include "ui/base/ui_base_switches.h" #include "type_conversion.h" #include <QByteArray> @@ -289,3 +291,12 @@ base::string16 WebEngineLibraryInfo::getApplicationName() { return toString16(qApp->applicationName()); } + +std::string WebEngineLibraryInfo::getApplicationLocale() +{ + CommandLine *parsedCommandLine = CommandLine::ForCurrentProcess(); + if (!parsedCommandLine->HasSwitch(switches::kLang)) + return QLocale().bcp47Name().toStdString(); + + return parsedCommandLine->GetSwitchValueASCII(switches::kLang); +} diff --git a/src/core/web_engine_library_info.h b/src/core/web_engine_library_info.h index cb7301b63..e85258078 100644 --- a/src/core/web_engine_library_info.h +++ b/src/core/web_engine_library_info.h @@ -49,6 +49,7 @@ public: static base::FilePath getPath(int key); // Called by localized_error in our custom chrome layer static base::string16 getApplicationName(); + static std::string getApplicationLocale(); }; diff --git a/tests/auto/quick/qmltests/tst_qmltests.cpp b/tests/auto/quick/qmltests/tst_qmltests.cpp index 4f4f847be..1ef8be582 100644 --- a/tests/auto/quick/qmltests/tst_qmltests.cpp +++ b/tests/auto/quick/qmltests/tst_qmltests.cpp @@ -49,6 +49,9 @@ int main(int argc, char **argv) qputenv("QML2_IMPORT_PATH", QByteArray(TESTS_SOURCE_DIR "qmltests/mock-delegates")); QScopedPointer<Application> app; + // Force to use English language for testing due to error message checks + QLocale::setDefault(QLocale("en")); + if (!QCoreApplication::instance()) app.reset(new Application(argc, argv)); QtWebEngine::initialize(); |