Skip to content

Commit 2345aaa

Browse files
committed
Mac: Fix --lang support
1 parent 8d336b6 commit 2345aaa

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/shell_main_delegate.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,17 @@ bool ShellMainDelegate::BasicStartupComplete(int* exit_code) {
138138
void ShellMainDelegate::PreSandboxStartup() {
139139
breakpad::SetBreakpadClient(g_chrome_breakpad_client.Pointer());
140140
CommandLine* command_line = CommandLine::ForCurrentProcess();
141+
std::string pref_locale;
142+
if (command_line->HasSwitch(switches::kLang)) {
143+
pref_locale = command_line->GetSwitchValueASCII(switches::kLang);
144+
}
141145

142146
#if defined(OS_MACOSX)
143147
OverrideFrameworkBundlePath();
144148
OverrideChildProcessPath();
145149
l10n_util::OverrideLocaleWithUserDefault();
146150
#endif // OS_MACOSX
147-
InitializeResourceBundle();
151+
InitializeResourceBundle(pref_locale);
148152

149153
std::string process_type =
150154
command_line->GetSwitchValueASCII(switches::kProcessType);
@@ -179,13 +183,13 @@ int ShellMainDelegate::RunProcess(
179183
return ShellBrowserMain(main_function_params);
180184
}
181185

182-
void ShellMainDelegate::InitializeResourceBundle() {
186+
void ShellMainDelegate::InitializeResourceBundle(const std::string& pref_locale) {
183187
FilePath pak_file;
184188
#if defined(OS_MACOSX)
185189
FilePath locale_file;
186190
if (!GetResourcesPakFilePath(pak_file))
187191
LOG(FATAL) << "nw.pak file not found.";
188-
std::string locale = l10n_util::GetApplicationLocale(std::string());
192+
std::string locale = l10n_util::GetApplicationLocale(pref_locale);
189193
if (!GetLocalePakFilePath(locale, locale_file))
190194
LOG(FATAL) << locale << ".pak file not found.";
191195
ui::ResourceBundle::InitSharedInstanceWithPakPath2(pak_file, locale_file);

src/shell_main_delegate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ShellMainDelegate : public ContentMainDelegate {
2828
virtual ContentBrowserClient* CreateContentBrowserClient() OVERRIDE;
2929
virtual ContentRendererClient* CreateContentRendererClient() OVERRIDE;
3030

31-
static void InitializeResourceBundle();
31+
static void InitializeResourceBundle(const std::string& pref_locale);
3232
#if defined(OS_POSIX) && !defined(OS_MACOSX)
3333
virtual void ZygoteForked() OVERRIDE;
3434
#endif

0 commit comments

Comments
 (0)