summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/extension_message_bundle.h
diff options
context:
space:
mode:
authorcira@chromium.org <cira@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-20 22:39:49 +0000
committercira@chromium.org <cira@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-20 22:39:49 +0000
commit4a5bbf82f2e1f3c9f54f7a8bdf9c4ee886000a41 (patch)
tree18cc711253814591982002ec90434d94f7b77516 /chrome/common/extensions/extension_message_bundle.h
parentbca52adc0eb1e48ff4966a38fd25218d585c3709 (diff)
downloadchromium_src-4a5bbf82f2e1f3c9f54f7a8bdf9c4ee886000a41.zip
chromium_src-4a5bbf82f2e1f3c9f54f7a8bdf9c4ee886000a41.tar.gz
chromium_src-4a5bbf82f2e1f3c9f54f7a8bdf9c4ee886000a41.tar.bz2
Add reserved messages to ExtensionMessageBundle dictionary. They are of the form @@somename, i.e. @@ui_locale.
It makes easier for developers to detect current UI locale (also available though window.navigator.language), or text direction. I'll use them for static message replacement later on too. Before this change developers would have to manualy add locale and text_dir messages and translate for all supported locales. Added 5 reserved messages: @@ui_locale @@bidi_dir @@bidi_reversed_dir @@bidi_start_edge @@bidi_end_edge See http://code.google.com/apis/gadgets/docs/i18n.html#BIDI on why are they usefull. Extended allowed charset for variable names with @. Added unittest for variable names. Review URL: http://codereview.chromium.org/546040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36693 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/extension_message_bundle.h')
-rw-r--r--chrome/common/extensions/extension_message_bundle.h34
1 files changed, 28 insertions, 6 deletions
diff --git a/chrome/common/extensions/extension_message_bundle.h b/chrome/common/extensions/extension_message_bundle.h
index b44805c..847c230 100644
--- a/chrome/common/extensions/extension_message_bundle.h
+++ b/chrome/common/extensions/extension_message_bundle.h
@@ -30,6 +30,21 @@ class ExtensionMessageBundle {
static const char* kMessageBegin;
static const char* kMessageEnd;
+ // Reserved message names in the dictionary.
+ // Update i18n documentation when adding new reserved value.
+ static const char* kUILocaleKey;
+ // See http://code.google.com/apis/gadgets/docs/i18n.html#BIDI for
+ // description.
+ // TODO(cira): point to chrome docs once they are out.
+ static const char* kBidiDirectionKey;
+ static const char* kBidiReversedDirectionKey;
+ static const char* kBidiStartEdgeKey;
+ static const char* kBidiEndEdgeKey;
+
+ // Values for some of the reserved messages.
+ static const char* kBidiLeftEdgeValue;
+ static const char* kBidiRightEdgeValue;
+
// Creates ExtensionMessageBundle or returns NULL if there was an error.
// Expects locale_catalogs to be sorted from more specific to less specific,
// with default catalog at the end.
@@ -68,16 +83,13 @@ class ExtensionMessageBundle {
std::string* message,
std::string* error);
- // Allow only ascii 0-9, a-z, A-Z, and _ in the variable name.
- // Returns false if the input is empty or if it has illegal characters.
- // Public for easier unittesting.
- template<typename str>
- static bool IsValidName(const str& name);
-
// Getter for dictionary_.
const SubstitutionMap* dictionary() const { return &dictionary_; }
private:
+ // Testing friend.
+ friend class ExtensionMessageBundleTest;
+
// Use Create to create ExtensionMessageBundle instance.
ExtensionMessageBundle();
@@ -87,6 +99,11 @@ class ExtensionMessageBundle {
// Returns false on error.
bool Init(const CatalogVector& locale_catalogs, std::string* error);
+ // Appends locale specific reserved messages to the dictionary.
+ // Returns false if there was a conflict with user defined messages.
+ bool AppendReservedMessagesForLocale(const std::string& application_locale,
+ 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
// of the message.
@@ -107,6 +124,11 @@ class ExtensionMessageBundle {
std::string* message,
std::string* error) const;
+ // Allow only ascii 0-9, a-z, A-Z, and _ in the variable name.
+ // Returns false if the input is empty or if it has illegal characters.
+ template<typename str>
+ static bool IsValidName(const str& name);
+
// Holds all messages for application locale.
SubstitutionMap dictionary_;
};