Index: ui/base/resource/resource_bundle.cc |
diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc |
index 2890c41b6e2e44c9e43bef6cddf6d63afe507a8a..efbeb40e28b10cb8b8eb2706cbf96755c12ed571 100644 |
--- a/ui/base/resource/resource_bundle.cc |
+++ b/ui/base/resource/resource_bundle.cc |
@@ -311,6 +311,12 @@ void ResourceBundle::OverrideLocalePakForTest(const base::FilePath& pak_path) { |
overridden_pak_path_ = pak_path; |
} |
+void ResourceBundle::OverrideLocaleStringResource( |
+ int message_id, |
+ const base::string16& string) { |
+ overridden_locale_strings_[message_id] = string; |
+} |
+ |
const base::FilePath& ResourceBundle::GetOverriddenPakPath() { |
return overridden_pak_path_; |
} |
@@ -318,6 +324,10 @@ const base::FilePath& ResourceBundle::GetOverriddenPakPath() { |
std::string ResourceBundle::ReloadLocaleResources( |
const std::string& pref_locale) { |
base::AutoLock lock_scope(*locale_resources_data_lock_); |
+ |
+ // Remove all overriden strings, as they will not be valid for the new locale. |
+ overridden_locale_strings_.clear(); |
+ |
UnloadLocaleResources(); |
return LoadLocaleResources(pref_locale); |
} |
@@ -443,6 +453,11 @@ base::string16 ResourceBundle::GetLocalizedString(int message_id) { |
// we're using them. |
base::AutoLock lock_scope(*locale_resources_data_lock_); |
+ IdToStringMap::const_iterator it = |
+ overridden_locale_strings_.find(message_id); |
+ if (it != overridden_locale_strings_.end()) |
+ return it->second; |
+ |
// If for some reason we were unable to load the resources , return an empty |
// string (better than crashing). |
if (!locale_resources_data_.get()) { |