add app.setLocale() (#11469)
* infrastructure for setLocale via klang * add documentation for setLocale * add test for setLocale * fix spec * add spec and update docs * fix carriage feeds on windows * SetLocale() sets LC_ALL on Linux * in SetLocale() on Linux, use g_setenv() * fix tyop: '#ifdef OSX_POSIX' * make the linter happy * improvements from review
This commit is contained in:
parent
e3f1d90854
commit
ca34978e73
9 changed files with 92 additions and 16 deletions
|
@ -42,17 +42,22 @@ bool SubprocessNeedsResourceBundle(const std::string& process_type) {
|
|||
|
||||
} // namespace
|
||||
|
||||
void InitializeResourceBundle(const std::string& locale) {
|
||||
// Load locales.
|
||||
ui::ResourceBundle::InitSharedInstanceWithLocale(
|
||||
locale, nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES);
|
||||
void LoadResourceBundle(const std::string& locale) {
|
||||
const bool initialized = ui::ResourceBundle::HasSharedInstance();
|
||||
if (initialized)
|
||||
ui::ResourceBundle::CleanupSharedInstance();
|
||||
|
||||
// Load other resource files.
|
||||
ui::ResourceBundle::InitSharedInstanceWithLocale(
|
||||
locale, nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES);
|
||||
|
||||
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
|
||||
bundle.ReloadLocaleResources(locale);
|
||||
|
||||
// Load other resource files.
|
||||
#if defined(OS_MACOSX)
|
||||
LoadCommonResources();
|
||||
#else
|
||||
base::FilePath pak_dir;
|
||||
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
|
||||
PathService::Get(base::DIR_MODULE, &pak_dir);
|
||||
bundle.AddDataPackFromPath(
|
||||
pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak")),
|
||||
|
@ -104,7 +109,7 @@ void MainDelegate::PreSandboxStartup() {
|
|||
// browser process as a command line flag.
|
||||
if (SubprocessNeedsResourceBundle(process_type)) {
|
||||
std::string locale = cmd.GetSwitchValueASCII(switches::kLang);
|
||||
InitializeResourceBundle(locale);
|
||||
LoadResourceBundle(locale);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue