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

Unified Diff: chrome/common/extensions/extension_message_bundle.h

Issue 293037: Implementing better 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/common/extensions/extension_message_bundle.h
===================================================================
--- chrome/common/extensions/extension_message_bundle.h (revision 29587)
+++ chrome/common/extensions/extension_message_bundle.h (working copy)
@@ -7,7 +7,9 @@
#include <map>
#include <string>
+#include <vector>
+#include "base/linked_ptr.h"
#include "base/values.h"
// Contains localized extension messages for one locale. Any messages that the
@@ -15,6 +17,7 @@
class ExtensionMessageBundle {
public:
typedef std::map<std::string, std::string> SubstitutionMap;
+ typedef std::vector<linked_ptr<DictionaryValue> > CatalogVector;
// JSON keys of interest for messages file.
static const wchar_t* kContentKey;
@@ -32,10 +35,10 @@
static const char* kExtensionDescription;
// Creates ExtensionMessageBundle or returns NULL if there was an error.
- static ExtensionMessageBundle* Create(
- const DictionaryValue& default_locale_catalog,
- const DictionaryValue& current_locale_catalog,
- std::string* error);
+ // Expects locale_catalogs to be sorted from more specific to less specific,
+ // with default catalog at the end.
+ static ExtensionMessageBundle* Create(const CatalogVector& locale_catalogs,
+ std::string* error);
// Get message from the catalog with given key.
// Returned message has all of the internal placeholders resolved to their
@@ -82,13 +85,11 @@
// Use Create to create ExtensionMessageBundle instance.
ExtensionMessageBundle();
- // Initializes the instance from the contents of two catalogs. If a key is not
- // present in current_locale_catalog, the value from default_local_catalog is
- // used instead.
+ // Initializes the instance from the contents of vector of catalogs.
+ // If the key is not present in more specific catalog we fall back to next one
+ // (less specific).
// Returns false on error.
- bool Init(const DictionaryValue& default_locale_catalog,
- const DictionaryValue& current_locale_catalog,
- std::string* error);
+ bool Init(const CatalogVector& locale_catalogs, std::string* error);
// Helper methods that navigate JSON tree and return simplified message.
// They replace all $PLACEHOLDERS$ with their value, and return just key/value
« no previous file with comments | « chrome/browser/extensions/extension_l10n_util_unittest.cc ('k') | chrome/common/extensions/extension_message_bundle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698