@@ -475,10 +475,6 @@ std::string ResourceBundle::LoadLocaleResources(const std::string& pref_locale,
475475 // "en" locale can be problematic on some systems, pre-win10 at least.
476476 if (app_locale == " en" )
477477 app_locale = " en-GB" ;
478- if (app_locale == " pl-PL" )
479- app_locale = " pl" ;
480- if (app_locale == " ru-RU" )
481- app_locale = " ru" ;
482478 base::FilePath locale_file_path = GetOverriddenPakPath ();
483479 if (locale_file_path.empty ())
484480 locale_file_path = GetLocaleFilePath (app_locale);
@@ -506,34 +502,41 @@ std::string ResourceBundle::LoadLocaleResources(const std::string& pref_locale,
506502
507503 if (auto result = data_pack->LoadFromPathWithError (locale_file_path);
508504 !result.has_value () && crash_on_failure) {
509- DataPack::ErrorState& error = result.error ();
510- // https://crbug.com/40688225 and https://crbug.com/394631579: Chrome can't
511- // start when the locale file cannot be loaded. Crash early and gather some
512- // data. Also print on screen for rapid verification.
513- LOG (ERROR) << locale_file_path;
514- // The local contained in prefs; provided by the caller.
515- SCOPED_CRASH_KEY_STRING32 (" LoadLocaleResources" , " pref_locale" ,
516- pref_locale);
517- // The app locale resolved from the pref value.
518- SCOPED_CRASH_KEY_STRING32 (" LoadLocaleResources" , " app_locale" , app_locale);
519- // The path to the (possibly overridden) file that could not be opened.
520- SCOPED_CRASH_KEY_STRING1024 (" LoadLocaleResources" , " locale_filepath" ,
521- locale_file_path.AsUTF8Unsafe ());
522-
523- // A ui::DataPack::FailureReason indicating what step during the attempt to
524- // load the file failed.
525- SCOPED_CRASH_KEY_NUMBER (" LoadLocaleResources" , " reason" ,
526- static_cast <int >(error.reason ));
527- // A last-error code on Windows; otherwise, errno. Only relevant if `reason`
528- // is `kOpenFile` (0) or `kMapFile` (1).
529- SCOPED_CRASH_KEY_NUMBER (" LoadLocaleResources" , " error" , error.error );
530- // The base::File::Error from opening the file. Only relevant if `reason` is
531- // `kOpenFile` (0). Most likely redundant given `error` above, but reporting
532- // anyway just in case.
533- SCOPED_CRASH_KEY_NUMBER (" LoadLocaleResources" , " file_error" ,
534- error.file_error );
535-
536- NOTREACHED ();
505+ // Try again with alternative path.
506+ size_t hypen = app_locale.find (" -" );
507+ if (hypen != std::string::npos) {
508+ locale_file_path = GetLocaleFilePath (app_locale.substr (0 , hypen));
509+ result = data_pack->LoadFromPathWithError (locale_file_path);
510+ }
511+ if (!result.has_value () && crash_on_failure) {
512+ DataPack::ErrorState& error = result.error ();
513+ // https://crbug.com/40688225 and https://crbug.com/394631579: Chrome can't
514+ // start when the locale file cannot be loaded. Crash early and gather some
515+ // data.
516+ // The local contained in prefs; provided by the caller.
517+ SCOPED_CRASH_KEY_STRING32 (" LoadLocaleResources" , " pref_locale" ,
518+ pref_locale);
519+ // The app locale resolved from the pref value.
520+ SCOPED_CRASH_KEY_STRING32 (" LoadLocaleResources" , " app_locale" , app_locale);
521+ // The path to the (possibly overridden) file that could not be opened.
522+ SCOPED_CRASH_KEY_STRING1024 (" LoadLocaleResources" , " locale_filepath" ,
523+ locale_file_path.AsUTF8Unsafe ());
524+
525+ // A ui::DataPack::FailureReason indicating what step during the attempt to
526+ // load the file failed.
527+ SCOPED_CRASH_KEY_NUMBER (" LoadLocaleResources" , " reason" ,
528+ static_cast <int >(error.reason ));
529+ // A last-error code on Windows; otherwise, errno. Only relevant if `reason`
530+ // is `kOpenFile` (0) or `kMapFile` (1).
531+ SCOPED_CRASH_KEY_NUMBER (" LoadLocaleResources" , " error" , error.error );
532+ // The base::File::Error from opening the file. Only relevant if `reason` is
533+ // `kOpenFile` (0). Most likely redundant given `error` above, but reporting
534+ // anyway just in case.
535+ SCOPED_CRASH_KEY_NUMBER (" LoadLocaleResources" , " file_error" ,
536+ error.file_error );
537+
538+ NOTREACHED ();
539+ }
537540 }
538541
539542 locale_resources_data_ = std::move (data_pack);
0 commit comments