Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6145)

Unified Diff: chrome/browser/extensions/extension_l10n_util.cc

Issue 316013: Loading local resources uses improved fallback algorithm.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_l10n_util.cc
===================================================================
--- chrome/browser/extensions/extension_l10n_util.cc (revision 29776)
+++ chrome/browser/extensions/extension_l10n_util.cc (working copy)
@@ -62,19 +62,15 @@
return true;
}
-// Converts all - into _, to be consistent with ICU and file system names.
-static std::string NormalizeLocale(const std::string& locale) {
+std::string NormalizeLocale(const std::string& locale) {
std::string normalized_locale(locale);
std::replace(normalized_locale.begin(), normalized_locale.end(), '-', '_');
return normalized_locale;
}
-// Produce a vector of parent locales for given locale.
-// It includes the current locale in the result.
-// sr_Cyrl_RS generates sr_Cyrl_RS, sr_Cyrl and sr.
-static void GetParentLocales(const std::string& current_locale,
- std::vector<std::string>* parent_locales) {
+void GetParentLocales(const std::string& current_locale,
+ std::vector<std::string>* parent_locales) {
std::string locale(NormalizeLocale(current_locale));
const int kNameCapacity = 256;
@@ -187,16 +183,22 @@
return ExtensionMessageBundle::Create(catalogs, error);
}
-FilePath GetL10nRelativePath(const FilePath& relative_resource_path) {
- // Get locale relative path.
- static std::string current_locale = l10n_util::GetApplicationLocale(L"");
- std::replace(current_locale.begin(), current_locale.end(), '-', '_');
+void GetL10nRelativePaths(const FilePath& relative_resource_path,
+ std::vector<FilePath>* l10n_paths) {
+ DCHECK(NULL != l10n_paths);
+ std::vector<std::string> locales;
+ static const std::string current_locale =
+ l10n_util::GetApplicationLocale(L"");
+ GetParentLocales(current_locale, &locales);
+
FilePath locale_relative_path;
- return locale_relative_path
- .AppendASCII(Extension::kLocaleFolder)
- .AppendASCII(current_locale)
- .Append(relative_resource_path);
+ for (size_t i = 0; i < locales.size(); ++i) {
+ l10n_paths->push_back(locale_relative_path
+ .AppendASCII(Extension::kLocaleFolder)
+ .AppendASCII(locales[i])
+ .Append(relative_resource_path));
+ }
}
} // namespace extension_l10n_util
« no previous file with comments | « chrome/browser/extensions/extension_l10n_util.h ('k') | chrome/browser/extensions/extension_l10n_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698