diff options
author | cira@chromium.org <cira@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-21 17:25:32 +0000 |
---|---|---|
committer | cira@chromium.org <cira@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-21 17:25:32 +0000 |
commit | 7b7de277898646dbe99146c31f67abc1511fe066 (patch) | |
tree | bcf5ec37b3beb5f85ab010ada5b1e08c86e379cb /chrome/common/extensions/extension_message_bundle.h | |
parent | 979a71a0bbdedb206ee0b5487f4cc934a68de33c (diff) | |
download | chromium_src-7b7de277898646dbe99146c31f67abc1511fe066.zip chromium_src-7b7de277898646dbe99146c31f67abc1511fe066.tar.gz chromium_src-7b7de277898646dbe99146c31f67abc1511fe066.tar.bz2 |
Add reserved messages to ExtensionMessageBundle dictionary. They are of the form @@somename, i.e. @@ui_locale.
Trying to re-land. It's the same as http://codereview.chromium.org/546040.
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.
TBR=jshin@chromium.org
Review URL: http://codereview.chromium.org/555021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36757 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/extension_message_bundle.h')
-rw-r--r-- | chrome/common/extensions/extension_message_bundle.h | 34 |
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_; }; |